From 5e924ef9c1cc722213270419dbfaac9b4bb23a95 Mon Sep 17 00:00:00 2001 From: Jon Shea Date: Thu, 27 Mar 2025 18:19:25 -0400 Subject: [PATCH] Add `-pending.txt` tests * `-pending.txt` test files, containing tests labeled with `:skip` that highlight known parsing issues in Scala syntax. * Updated `CONTRIBUTING.md` with a brief explanation of the `-pending.txt` test files. --- CONTRIBUTING.md | 4 +++ test/corpus/definitions-pending.txt | 17 ++++++++++++ test/corpus/expressions-pending.txt | 43 +++++++++++++++++++++++++++++ test/corpus/patterns-pending.txt | 12 ++++++++ test/corpus/types-pending.txt | 40 +++++++++++++++++++++++++++ 5 files changed, 116 insertions(+) create mode 100644 test/corpus/definitions-pending.txt create mode 100644 test/corpus/expressions-pending.txt create mode 100644 test/corpus/patterns-pending.txt create mode 100644 test/corpus/types-pending.txt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6701860..074086f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,6 +43,10 @@ Then adjust as necessary. Note that depending on your change you may also have to touch the `/src/scanner.c` file if you need more advanced features like look-ahead. +## Pending Tests + +In `./test/corpus`, there are several files named `*-pending.txt`. These contain tests labeled with `:skip`, meaning they are not currently run. Each test includes examples of valid Scala syntax that `tree-sitter-scala` is known to fail to parse. If you’d like to contribute to `tree-sitter-scala`, a good place to start is by trying to fix one of these tests. + ## Syntax highlighting Right now the most common use-case for syntax highlight using tree-sitter is diff --git a/test/corpus/definitions-pending.txt b/test/corpus/definitions-pending.txt new file mode 100644 index 0000000..08436e4 --- /dev/null +++ b/test/corpus/definitions-pending.txt @@ -0,0 +1,17 @@ +================================================================================ +Function without parens +:skip +================================================================================ + +// https://github.com/scala/scala3/blob/main/tests/pos/multiLineOps.scala#L15 +send_! "!" + +-------------------------------------------------------------------------------- + +================================================================================ +Types of lambda parameters without parenthesis +:skip +================================================================================ + +// https://github.com/tree-sitter/tree-sitter-scala/issues/361 +xs.map { x: Int => x } \ No newline at end of file diff --git a/test/corpus/expressions-pending.txt b/test/corpus/expressions-pending.txt new file mode 100644 index 0000000..2344008 --- /dev/null +++ b/test/corpus/expressions-pending.txt @@ -0,0 +1,43 @@ +================================================================================ +Trailing coma after for comprehension in lambda parameter of a function +:skip +================================================================================ + +// https://github.com/tree-sitter/tree-sitter-scala/issues/449 +object Foo: + def foo(f: Option[Int] => Option[Int]): Option[Int] = f(None) + + foo(o => + for { + a <- o + } yield a, + ) + +-------------------------------------------------------------------------------- + +================================================================================ +Lambda expression with semicolon +:skip +================================================================================ + +// https://github.com/tree-sitter/tree-sitter-scala/issues/389 +TypeTreeWithDeferredRefCheck() { () => val tp = qual.tpe; val sym = tp.typeSymbolDirect + 1 +} + +val l1 = { () => val x = 1; 2 } + +-------------------------------------------------------------------------------- + +================================================================================ +infix_expression across multiple lines +:skip +================================================================================ + +// https://github.com/tree-sitter/tree-sitter-scala/issues/141 +def foo: Boolean = + x + || a.b(c) + +-------------------------------------------------------------------------------- + diff --git a/test/corpus/patterns-pending.txt b/test/corpus/patterns-pending.txt new file mode 100644 index 0000000..b524e44 --- /dev/null +++ b/test/corpus/patterns-pending.txt @@ -0,0 +1,12 @@ +================================================================================ +Infix types in match type cases +:skip +================================================================================ + +// https://github.com/tree-sitter/tree-sitter-scala/issues/360 +type F[T] = T match { + case t *: EmptyTuple => t + case t *: rest => t +} + +-------------------------------------------------------------------------------- diff --git a/test/corpus/types-pending.txt b/test/corpus/types-pending.txt new file mode 100644 index 0000000..adc2862 --- /dev/null +++ b/test/corpus/types-pending.txt @@ -0,0 +1,40 @@ + +================================================================================ +Subclass with multiline params and unnamed after named param +:skip +================================================================================ + +// https://github.com/tree-sitter/tree-sitter-scala/issues/465 +// https://github.com/scala/scala3/blob/main/tests/run/i14164.scala#L5-L9 +class Child extends Base( + param = + for x <- Seq("a") yield x + "param" +) + +-------------------------------------------------------------------------------- + +================================================================================ +case class nested in an object definition +:skip +================================================================================ + +// https://github.com/tree-sitter/tree-sitter-scala/issues/329 +object Merge: + + case class Location(runIndex: Int, locationInRun: String): + end Location + +end Merge + +-------------------------------------------------------------------------------- + +================================================================================ +More than two argument lists in `extends` +:skip +================================================================================ + +// https://github.com/tree-sitter/tree-sitter-scala/issues/259 +class A extends B(c)(d)(e) + +--------------------------------------------------------------------------------