blob: 17b0d5fcb13786c2e76831c56a1cda0506b5349b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package torimatomeru
import org.parboiled2.ParseError
import utest._
import utest.framework.Test
import utest.util.Tree
import scala.util.{Failure, Success}
object SyntaxTest extends TestSuite{
def check[T](input: String, parse: ScalaSyntax => scala.util.Try[T], expected: T) = {
parse(new ScalaSyntax(input)) match{
case Failure(f: ParseError) =>
println(f.formatTraces)
throw new Exception(f.formatTraces)
case Success(parsed) =>
assert(parsed == expected)
}
}
def tests = TestSuite{
* - check(
"""(1
|)""".stripMargin,
_.ArgumentExprs().run(), ()
)
* - check(
"""(1,
|1)""".stripMargin,
_.ArgumentExprs().run(), ()
)
* - check(
"""val omg = "omg"
|omg * 2""".stripMargin,
_.Block.run(), ()
)
}
}
|