@@ -14,23 +14,23 @@ import ReplTest._
14
14
class ReplCompilerTests extends ReplTest {
15
15
16
16
@ Test def compileSingle : Unit = fromInitialState { implicit state =>
17
- compiler.compile(" def foo: 1 = 1" ).stateOrFail
17
+ compiler.compile(" def foo: 1 = 1" .toParsed ).stateOrFail
18
18
}
19
19
20
20
21
21
@ Test def compileTwo =
22
22
fromInitialState { implicit state =>
23
- compiler.compile(" def foo: 1 = 1" ).stateOrFail
23
+ compiler.compile(" def foo: 1 = 1" .toParsed ).stateOrFail
24
24
}
25
25
.andThen { implicit state =>
26
- val s2 = compiler.compile(" def foo(i: Int): i.type = i" ).stateOrFail
26
+ val s2 = compiler.compile(" def foo(i: Int): i.type = i" .toParsed ).stateOrFail
27
27
assert(s2.objectIndex == 2 ,
28
28
s " Wrong object offset: expected 2 got ${s2.objectIndex}" )
29
29
}
30
30
31
31
@ Test def inspectSingle =
32
32
fromInitialState { implicit state =>
33
- val untpdTree = compiler.compile(" def foo: 1 = 1" ).map(_._1.untpdTree)
33
+ val untpdTree = compiler.compile(" def foo: 1 = 1" .toParsed ).map(_._1.untpdTree)
34
34
35
35
untpdTree.fold(
36
36
onErrors,
@@ -44,7 +44,7 @@ class ReplCompilerTests extends ReplTest {
44
44
}
45
45
46
46
@ Test def testVar = fromInitialState { implicit state =>
47
- compile(" var x = 5" )
47
+ compile(" var x = 5" .toParsed )
48
48
assertEquals(" var x: Int = 5\n " , storedOutput())
49
49
}
50
50
@@ -54,7 +54,7 @@ class ReplCompilerTests extends ReplTest {
54
54
|val x = 5 + 5
55
55
|1 + 1
56
56
|var y = 5
57
- |10 + 10""" .stripMargin
57
+ |10 + 10""" .stripMargin.toParsed
58
58
}
59
59
60
60
val expected = Set (" def foo: Int" ,
@@ -68,12 +68,12 @@ class ReplCompilerTests extends ReplTest {
68
68
69
69
@ Test def testImportMutable =
70
70
fromInitialState { implicit state =>
71
- compile(" import scala.collection.mutable" )
71
+ compile(" import scala.collection.mutable" .toParsed )
72
72
}
73
73
.andThen { implicit state =>
74
74
assert(state.imports.nonEmpty, " Didn't add import to `State` after compilation" )
75
75
76
- compile(""" mutable.Map("one" -> 1)""" )
76
+ compile(""" mutable.Map("one" -> 1)""" .toParsed )
77
77
78
78
assertEquals(
79
79
" val res0: scala.collection.mutable.Map[String, Int] = Map(one -> 1)\n " ,
@@ -82,9 +82,9 @@ class ReplCompilerTests extends ReplTest {
82
82
}
83
83
84
84
@ Test def rebindVariable =
85
- fromInitialState { implicit s => compile(" var x = 5" ) }
85
+ fromInitialState { implicit s => compile(" var x = 5" .toParsed ) }
86
86
.andThen { implicit s =>
87
- compile(" x = 10" )
87
+ compile(" x = 10" .toParsed )
88
88
assertEquals(
89
89
""" |var x: Int = 5
90
90
|x: Int = 10
@@ -96,28 +96,28 @@ class ReplCompilerTests extends ReplTest {
96
96
// FIXME: Tests are not run in isolation, the classloader is corrupted after the first exception
97
97
@ Ignore def i3305 : Unit = {
98
98
fromInitialState { implicit s =>
99
- compile(" null.toString" )
99
+ compile(" null.toString" .toParsed )
100
100
assertTrue(storedOutput().startsWith(" java.lang.NullPointerException" ))
101
101
}
102
102
103
103
fromInitialState { implicit s =>
104
- compile(" def foo: Int = 1 + foo; foo" )
104
+ compile(" def foo: Int = 1 + foo; foo" .toParsed )
105
105
assertTrue(storedOutput().startsWith(" def foo: Int\n java.lang.StackOverflowError" ))
106
106
}
107
107
108
108
fromInitialState { implicit s =>
109
- compile(""" throw new IllegalArgumentException("Hello")""" )
109
+ compile(""" throw new IllegalArgumentException("Hello")""" .toParsed )
110
110
assertTrue(storedOutput().startsWith(" java.lang.IllegalArgumentException: Hello" ))
111
111
}
112
112
113
113
fromInitialState { implicit s =>
114
- compile(" val (x, y) = null" )
114
+ compile(" val (x, y) = null" .toParsed )
115
115
assertTrue(storedOutput().startsWith(" scala.MatchError: null" ))
116
116
}
117
117
}
118
118
119
119
@ Test def i2789 : Unit = fromInitialState { implicit state =>
120
- compile(" (x: Int) => println(x)" )
120
+ compile(" (x: Int) => println(x)" .toParsed )
121
121
assertTrue(storedOutput().startsWith(" val res0: Int => Unit =" ))
122
122
}
123
123
}
0 commit comments