From 94ab884ee4d0b965c8c16212979e15927976f068 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Wed, 5 Aug 2020 12:16:09 -0400 Subject: [PATCH] Add a test. --- cli/src/tests/tags_test.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/cli/src/tests/tags_test.rs b/cli/src/tests/tags_test.rs index 88e57ec1..2b058c0b 100644 --- a/cli/src/tests/tags_test.rs +++ b/cli/src/tests/tags_test.rs @@ -297,6 +297,39 @@ fn test_invalid_capture() { assert_eq!(e, Error::InvalidCapture("method".to_string())); } +#[test] +fn test_tags_with_parse_error() { + let language = get_language("python"); + let tags_config = TagsConfiguration::new(language, PYTHON_TAG_QUERY, "").unwrap(); + let mut tag_context = TagsContext::new(); + + let source = br#" + class Fine: pass + class Bad + "#; + + let (tags, failed) = tag_context + .generate_tags(&tags_config, source, None) + .unwrap(); + + let newtags = tags.collect::, _>>().unwrap(); + + assert!(failed, "syntax error should have been detected"); + + assert_eq!( + newtags.iter() + .map(|t| ( + substr(source, &t.name_range), + tags_config.syntax_type_name(t.syntax_type_id) + )) + .collect::>(), + &[ + ("Fine", "class"), + ] + ); +} + + #[test] fn test_tags_via_c_api() { allocations::record(|| {