@@ -2,6 +2,7 @@ package dotc
2
2
3
3
import dotty .Jars
4
4
import dotty .tools .dotc .CompilerTest
5
+ import dotty .tools .StdLibSources
5
6
import org .junit .{Before , Test }
6
7
import org .junit .Assert ._
7
8
@@ -201,46 +202,33 @@ class tests extends CompilerTest {
201
202
202
203
@ Test def run_all = runFiles(runDir)
203
204
204
- def loadList (path : String ) = Source .fromFile(path, " UTF8" ).getLines()
205
- .map(_.trim) // allow identation
206
- .filter(! _.startsWith(" #" )) // allow comment lines prefixed by #
207
- .map(_.takeWhile(_ != '#' ).trim) // allow comments in the end of line
208
- .filter(_.nonEmpty)
209
- .toList
210
-
211
- private def stdlibWhitelistFile = " ./test/dotc/scala-collections.whitelist"
212
- private def stdlibBlackFile = " ./test/dotc/scala-collections.blacklist"
213
-
214
- private val stdlibFiles : List [String ] = loadList(stdlibWhitelistFile)
205
+ private val stdlibFiles : List [String ] = StdLibSources .whitelisted
215
206
216
207
@ Test def checkWBLists = {
217
- val stdlibFilesBlackListed = loadList(stdlibBlackFile)
208
+ import StdLibSources .{whitelistFile , blacklistFile }
209
+
210
+ val stdlibFilesBlackListed = StdLibSources .blacklisted
218
211
219
212
def checkForRepeated (list : List [String ], listFile : String ) = {
220
213
val duplicates = list.groupBy(x => x).filter(_._2.size > 1 ).filter(_._2.size > 1 )
221
214
val msg = duplicates.map(x => s " ' ${x._1}' appears ${x._2.size} times " ).mkString(s " Duplicate entries in $listFile: \n " , " \n " , " \n " )
222
215
assertTrue(msg, duplicates.isEmpty)
223
216
}
224
- checkForRepeated(stdlibFiles, stdlibWhitelistFile )
225
- checkForRepeated(stdlibFilesBlackListed, stdlibBlackFile )
217
+ checkForRepeated(stdlibFiles, whitelistFile )
218
+ checkForRepeated(stdlibFilesBlackListed, blacklistFile )
226
219
227
220
val whitelistSet = stdlibFiles.toSet
228
221
val blacklistSet = stdlibFilesBlackListed.toSet
229
222
230
223
val intersection = whitelistSet.intersect(blacklistSet)
231
224
val msgIntersection =
232
- intersection.map(x => s " ' $x' " ).mkString(s " Entries where found in both $stdlibWhitelistFile and $stdlibBlackFile : \n " , " \n " , " \n " )
225
+ intersection.map(x => s " ' $x' " ).mkString(s " Entries where found in both $whitelistFile and $blacklistFile : \n " , " \n " , " \n " )
233
226
assertTrue(msgIntersection, intersection.isEmpty)
234
227
235
- def collectAllFilesInDir (dir : JFile , acc : List [String ]): List [String ] = {
236
- val files = dir.listFiles()
237
- val acc2 = files.foldLeft(acc)((acc1, file) => if (file.isFile && file.getPath.endsWith(" .scala" )) file.getPath :: acc1 else acc1)
238
- files.foldLeft(acc2)((acc3, file) => if (file.isDirectory) collectAllFilesInDir(file, acc3) else acc3)
239
- }
240
- val filesInStdLib = collectAllFilesInDir(new JFile (" ../scala-scala/src/library/" ), Nil )
228
+ val filesInStdLib = StdLibSources .all
241
229
val missingFiles = filesInStdLib.toSet -- whitelistSet -- blacklistSet
242
230
val msgMissing =
243
- missingFiles.map(x => s " ' $x' " ).mkString(s " Entries are missing in $stdlibWhitelistFile or $stdlibBlackFile : \n " , " \n " , " \n " )
231
+ missingFiles.map(x => s " ' $x' " ).mkString(s " Entries are missing in $whitelistFile or $blacklistFile : \n " , " \n " , " \n " )
244
232
assertTrue(msgMissing, missingFiles.isEmpty)
245
233
}
246
234
0 commit comments