aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotty/tools/dotc/parsing/ParserTest.scala
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/test/dotty/tools/dotc/parsing/ParserTest.scala')
-rw-r--r--compiler/test/dotty/tools/dotc/parsing/ParserTest.scala44
1 files changed, 44 insertions, 0 deletions
diff --git a/compiler/test/dotty/tools/dotc/parsing/ParserTest.scala b/compiler/test/dotty/tools/dotc/parsing/ParserTest.scala
new file mode 100644
index 000000000..a89b34512
--- /dev/null
+++ b/compiler/test/dotty/tools/dotc/parsing/ParserTest.scala
@@ -0,0 +1,44 @@
+package dotty.tools
+package dotc
+package parsing
+
+import scala.reflect.io._
+import util._
+import core._
+import scala.io.Codec
+import Tokens._, Parsers._
+import ast.untpd._
+import org.junit.Test
+import scala.collection.mutable.ListBuffer
+
+class ParserTest extends DottyTest {
+
+ def parse(name: String): Tree = parse(new PlainFile(name))
+
+ var parsed = 0
+ val parsedTrees = new ListBuffer[Tree]
+
+ def reset() = {
+ parsed = 0
+ parsedTrees.clear()
+ }
+
+ def parse(file: PlainFile): Tree = {
+ //println("***** parsing " + file)
+ val source = new SourceFile(file, Codec.UTF8)
+ val parser = new Parser(source)
+ val tree = parser.parse()
+ parsed += 1
+ parsedTrees += tree
+ tree
+ }
+
+ def parseDir(path: String): Unit = parseDir(Directory(path))
+
+ def parseDir(dir: Directory): Unit = {
+ for (f <- dir.files)
+ if (f.name.endsWith(".scala")) parse(new PlainFile(f))
+ for (d <- dir.dirs)
+ parseDir(d.path)
+ }
+}