1
1
package dotty .tools .repl
2
2
3
3
import java .nio .file .{ Path , Files }
4
+ import java .util .Comparator
4
5
5
6
import org .junit .{ Test , BeforeClass , AfterClass }
6
7
import org .junit .Assert .assertEquals
@@ -9,8 +10,11 @@ class LoadTests extends ReplTest {
9
10
import LoadTests ._
10
11
11
12
@ Test def helloworld = loadTest(
12
- file = """ def helloWorld = "Hello, World!"""" ,
13
- defs = """ |def helloWorld: String
13
+ file = """ |def helloWorld = "Hello, World!"
14
+ |println(helloWorld)
15
+ |""" .stripMargin,
16
+ defs = """ |Hello, World!
17
+ |def helloWorld: String
14
18
|
15
19
|
16
20
|""" .stripMargin,
@@ -21,7 +25,8 @@ class LoadTests extends ReplTest {
21
25
)
22
26
23
27
@ Test def maindef = loadTest(
24
- file = """ @main def helloWorld = println("Hello, World!")""" ,
28
+ file = """ |@main def helloWorld = println("Hello, World!")
29
+ |""" .stripMargin,
25
30
defs = """ |def helloWorld: Unit
26
31
|
27
32
|
@@ -34,7 +39,8 @@ class LoadTests extends ReplTest {
34
39
35
40
@ Test def maindefs = loadTest(
36
41
file = """ |@main def helloWorld = println("Hello, World!")
37
- |@main def helloTo(name: String) = println(s"Hello, $name!")""" .stripMargin,
42
+ |@main def helloTo(name: String) = println(s"Hello, $name!")
43
+ |""" .stripMargin,
38
44
defs = """ |def helloTo(name: String): Unit
39
45
|def helloWorld: Unit
40
46
|
@@ -67,11 +73,10 @@ object LoadTests {
67
73
dir = Files .createTempDirectory(" repl_load_src" )
68
74
69
75
@ AfterClass def removeDir : Unit =
70
- Files .walk(dir).filter(! Files .isDirectory(_)).forEach(Files .delete)
71
- Files .delete(dir)
76
+ Files .walk(dir).sorted(Comparator .reverseOrder).forEach(Files .delete)
72
77
dir = null
73
78
74
- def writeFile (contents : String ): Path = {
79
+ private def writeFile (contents : String ): Path = {
75
80
val file = Files .createTempFile(dir, " repl_test" , " .scala" )
76
81
Files .write(file, contents.getBytes)
77
82
file
0 commit comments