From 422e74fbdbba3ea1edaafdb63be9da179a311593 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 2 Feb 2024 08:47:33 -0500 Subject: [PATCH] chore: update javascript-relevant tests --- cli/src/tests/highlight_test.rs | 3 ++- cli/src/tests/parser_test.rs | 10 +++++----- cli/src/tests/query_test.rs | 18 +++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/cli/src/tests/highlight_test.rs b/cli/src/tests/highlight_test.rs index 12c120ab..b43bb0c6 100644 --- a/cli/src/tests/highlight_test.rs +++ b/cli/src/tests/highlight_test.rs @@ -329,10 +329,11 @@ fn test_highlighting_empty_lines() { fn test_highlighting_carriage_returns() { let source = "a = \"a\rb\"\r\nb\r"; + // FIXME(amaanq): figure why this changed w/ JS's grammar changes assert_eq!( &to_html(source, &JS_HIGHLIGHT).unwrap(), &[ - "a = "ab"\n", + "a = "ab"\n", "b\n", ], ); diff --git a/cli/src/tests/parser_test.rs b/cli/src/tests/parser_test.rs index a223a453..ff8818fe 100644 --- a/cli/src/tests/parser_test.rs +++ b/cli/src/tests/parser_test.rs @@ -858,16 +858,16 @@ fn test_parsing_with_multiple_included_ranges() { let template_string_node = js_tree .root_node() .descendant_for_byte_range( - source_code.find("
").unwrap(), - source_code.find("Hello").unwrap(), + source_code.find("`<").unwrap(), + source_code.find(">`").unwrap(), ) .unwrap(); assert_eq!(template_string_node.kind(), "template_string"); let open_quote_node = template_string_node.child(0).unwrap(); - let interpolation_node1 = template_string_node.child(1).unwrap(); - let interpolation_node2 = template_string_node.child(2).unwrap(); - let close_quote_node = template_string_node.child(3).unwrap(); + let interpolation_node1 = template_string_node.child(2).unwrap(); + let interpolation_node2 = template_string_node.child(4).unwrap(); + let close_quote_node = template_string_node.child(6).unwrap(); parser.set_language(&get_language("html")).unwrap(); let html_ranges = &[ diff --git a/cli/src/tests/query_test.rs b/cli/src/tests/query_test.rs index 4b26a5d9..c6cbbe0a 100644 --- a/cli/src/tests/query_test.rs +++ b/cli/src/tests/query_test.rs @@ -377,7 +377,7 @@ fn test_query_errors_on_impossible_patterns() { Query::new( &js_lang, "[ - (function (identifier)) + (function_expression (identifier)) (function_declaration (identifier)) (generator_function_declaration (identifier)) ]", @@ -387,7 +387,7 @@ fn test_query_errors_on_impossible_patterns() { Query::new( &js_lang, "[ - (function (identifier)) + (function_expression (identifier)) (function_declaration (object)) (generator_function_declaration (identifier)) ]", @@ -395,7 +395,7 @@ fn test_query_errors_on_impossible_patterns() { Err(QueryError { kind: QueryErrorKind::Structure, row: 2, - offset: 88, + offset: 99, column: 42, message: [ " (function_declaration (object))", // @@ -589,7 +589,7 @@ fn test_query_matches_with_multiple_patterns_same_root() { " (pair key: (property_identifier) @method-def - value: (function)) + value: (function_expression)) (pair key: (property_identifier) @method-def @@ -1499,7 +1499,7 @@ fn test_query_matches_with_simple_alternatives() { " (pair key: [(property_identifier) (string)] @key - value: [(function) @val1 (arrow_function) @val2]) + value: [(function_expression) @val1 (arrow_function) @val2]) ", ) .unwrap(); @@ -2835,12 +2835,12 @@ fn test_query_captures_basic() { r#" (pair key: _ @method.def - (function + (function_expression name: (identifier) @method.alias)) (variable_declarator name: _ @function.def - value: (function + value: (function_expression name: (identifier) @function.alias)) ":" @delimiter @@ -3078,7 +3078,7 @@ fn test_query_captures_with_duplicates() { r#" (variable_declarator name: (identifier) @function - value: (function)) + value: (function_expression)) (identifier) @variable "#, @@ -4498,7 +4498,7 @@ fn test_capture_quantifiers() { language: get_language("javascript"), pattern: r#"[ (function_declaration name:(identifier) @name) - (function) + (function_expression) ] @fun"#, capture_quantifiers: &[ (0, "fun", CaptureQuantifier::One),