@konomanoasa/tree-sitter-query 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -268,6 +268,19 @@ fn string_leaves_preserve_literal_bytes_and_escape_spelling() {
268
268
  ("\"", 9..10),
269
269
  ],
270
270
  ),
271
+ (
272
+ "\";x\0\"",
273
+ vec![("\"", 0..1), ("string_content", 1..4), ("\"", 4..5)],
274
+ ),
275
+ (
276
+ "\"\\\n;x\0\"",
277
+ vec![
278
+ ("\"", 0..1),
279
+ ("escape_sequence", 1..3),
280
+ ("string_content", 3..6),
281
+ ("\"", 6..7),
282
+ ],
283
+ ),
271
284
  (
272
285
  "\"a\0b\0\0c\"",
273
286
  vec![("\"", 0..1), ("string_content", 1..7), ("\"", 7..8)],
@@ -318,6 +331,27 @@ fn string_leaves_preserve_literal_bytes_and_escape_spelling() {
318
331
  }
319
332
  }
320
333
 
334
+ #[test]
335
+ fn string_newlines_cannot_skip_comments_before_nul() {
336
+ let language = grammar::LANGUAGE.into();
337
+ let mut parser = parser();
338
+ for (source, api_error) in [
339
+ ("\"\n;x\0\"", QueryErrorKind::Syntax),
340
+ ("(#custom? \"\n;x\0\")", QueryErrorKind::Syntax),
341
+ ("(#custom! \"\n;x\0\")", QueryErrorKind::Syntax),
342
+ ("(identifier/\"\n;x\0\")", QueryErrorKind::Structure),
343
+ ] {
344
+ assert_eq!(
345
+ Query::new(&language, source).unwrap_err().kind,
346
+ api_error,
347
+ "{source:?}"
348
+ );
349
+ let tree = parser.parse(source, None).unwrap();
350
+ assert!(tree.root_node().has_error(), "{source:?}");
351
+ assert_eq!(tree.root_node().byte_range(), 0..source.len());
352
+ }
353
+ }
354
+
321
355
  #[test]
322
356
  fn carriage_returns_inside_comments_preserve_the_following_pattern() {
323
357
  let language = grammar::LANGUAGE.into();
package/tree-sitter.json CHANGED
@@ -12,7 +12,7 @@
12
12
  }
13
13
  ],
14
14
  "metadata": {
15
- "version": "0.2.0",
15
+ "version": "0.3.0",
16
16
  "license": "MIT",
17
17
  "description": "Tree-sitter grammar for Tree-sitter Query.",
18
18
  "links": {