aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotty/tools/StdLibSources.scala
diff options
context:
space:
mode:
authorNicolas Stucki <nicolas.stucki@gmail.com>2017-01-05 11:08:26 +0100
committerNicolas Stucki <nicolas.stucki@gmail.com>2017-01-05 11:08:26 +0100
commit66a340937b0adead0aa7a96e21f68d43a03cba00 (patch)
treec29d139a36a2ecb5db669b613100b63a6dfb5a5f /compiler/test/dotty/tools/StdLibSources.scala
parent3922cce7afc295f7816397ebf2d2f59446a89041 (diff)
downloaddotty-66a340937b0adead0aa7a96e21f68d43a03cba00.tar.gz
dotty-66a340937b0adead0aa7a96e21f68d43a03cba00.tar.bz2
dotty-66a340937b0adead0aa7a96e21f68d43a03cba00.zip
Add stdlib whitelist loader.
Diffstat (limited to 'compiler/test/dotty/tools/StdLibSources.scala')
-rw-r--r--compiler/test/dotty/tools/StdLibSources.scala31
1 files changed, 31 insertions, 0 deletions
diff --git a/compiler/test/dotty/tools/StdLibSources.scala b/compiler/test/dotty/tools/StdLibSources.scala
new file mode 100644
index 000000000..9afb81d20
--- /dev/null
+++ b/compiler/test/dotty/tools/StdLibSources.scala
@@ -0,0 +1,31 @@
+package dotty.tools
+
+import java.io.File
+
+import scala.io.Source
+
+object StdLibSources {
+
+ def whitelistFile: String = "./test/dotc/scala-collections.whitelist"
+ def blacklistFile: String = "./test/dotc/scala-collections.blacklist"
+
+ def whitelisted: List[String] = loadList(whitelistFile)
+ def blacklisted: List[String] = loadList(blacklistFile)
+
+ def all: List[String] = {
+ def collectAllFilesInDir(dir: File, acc: List[String]): List[String] = {
+ val files = dir.listFiles()
+ val acc2 = files.foldLeft(acc)((acc1, file) => if (file.isFile && file.getPath.endsWith(".scala")) file.getPath :: acc1 else acc1)
+ files.foldLeft(acc2)((acc3, file) => if (file.isDirectory) collectAllFilesInDir(file, acc3) else acc3)
+ }
+ collectAllFilesInDir(new File("../scala-scala/src/library/"), Nil)
+ }
+
+ private def loadList(path: String): List[String] = Source.fromFile(path, "UTF8").getLines()
+ .map(_.trim) // allow identation
+ .filter(!_.startsWith("#")) // allow comment lines prefixed by #
+ .map(_.takeWhile(_ != '#').trim) // allow comments in the end of line
+ .filter(_.nonEmpty)
+ .toList
+
+}