summaryrefslogtreecommitdiff
path: root/scalatexApi/src/test/scala/torimatomeru/SyntaxTest.scala
blob: 4562dbdee5014fb2e00ddf552615422855ea5278 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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) = {
    new ScalaSyntax(input).CompilationUnit.run() match{
      case Failure(f: ParseError) =>
        println(f.formatTraces)
        throw new Exception(f.position + "\t" + f.formatTraces)
      case Success(parsed) =>
        assert(parsed == input)
    }
  }
  def tests = TestSuite{

    * - check(
      "package torimatomeru"

    )
    * - check(
      """
        |package torimatomeru
        |
        |import org.parboiled2.ParseError
        |import utest._
        |import utest.framework.Test
      """.stripMargin

    )
    * - check(
      """
        |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
      """.stripMargin
    )
    * - check(
      """
        |object SyntaxTest extends TestSuite{
        |  def check[T](input: String) = {
        |
        |  }
        |}
      """.stripMargin
    )
  }
}