Skip to content

Commit d0ef2aa

Browse files
committed
Add more evaluation tests
1 parent 12212bf commit d0ef2aa

40 files changed

+672
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
break Test$ 6
2+
eval x + 1
3+
result 4
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Test:
2+
def main(args: Array[String]): Unit =
3+
foo(3)()
4+
5+
def foo(x: Int)(
6+
y: Int = x + 1
7+
): Unit =
8+
println("foo")

tests/debug/eval-captures.check

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
break A 26
2+
eval (new B).m
3+
result x1x2x3x4
4+
5+
break A$B$1 22
6+
eval x1
7+
result x1
8+
eval m // local def m
9+
result x1x2x3x4
10+
eval (new B).m
11+
result x1x2x3x4
12+
eval A.this.m // compiles but throws NoSuchFieldException
13+
result java.lang.NoSuchFieldException: $outer
14+
15+
break A$B$1 21
16+
eval x1
17+
result x1
18+
eval x2
19+
result x2
20+
eval m
21+
result x1x2x3x4
22+
eval (new C).m
23+
result x1x2x3x4
24+
eval (new B).m
25+
result x1x2x3x4
26+
27+
break A$B$1$C$1 19
28+
eval x1
29+
result x1
30+
eval x2
31+
result x2
32+
eval x3
33+
result x3
34+
eval x4
35+
result x4
36+
eval m
37+
result x1x2x3x4
38+
eval (new C).m
39+
result x1x2x3x4
40+
eval (new B).m
41+
result x1x2x3x4
42+
43+
break A$B$1$C$1 18
44+
eval x1
45+
result x1
46+
eval x2
47+
result x2
48+
eval x3
49+
result x3
50+
eval x4
51+
result x4
52+
eval m
53+
result x1x2x3x4
54+
eval (new C).m
55+
result x1x2x3x4
56+
eval (new B).m
57+
result x1x2x3x4

tests/debug/eval-captures.scala

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
object Test:
2+
def main(args: Array[String]): Unit =
3+
val a = new A
4+
println(a.m)
5+
6+
class A:
7+
def m: String =
8+
val x1 = "x1"
9+
class B:
10+
def m: String =
11+
val x2 = "x2"
12+
def m: String =
13+
val x3 = "x3"
14+
class C:
15+
def m: String =
16+
val x4 = "x4"
17+
def m: String =
18+
x1 + x2 + x3 + x4
19+
m
20+
val c = new C
21+
c.m
22+
m
23+
end m
24+
end B
25+
val b = new B
26+
b.m

tests/debug/eval-exception.check

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
break Test$ 7
2+
eval throwException()
3+
result java.lang.Exception: foo
4+
eval throw new Exception("bar")
5+
result java.lang.Exception: bar
6+
eval
7+
try throwException()
8+
catch case e: Exception => "caught"
9+
result caught

tests/debug/eval-exception.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object Test:
2+
def main(args: Array[String]): Unit =
3+
try throwException()
4+
catch case e: Exception => ()
5+
6+
def throwException(): Unit =
7+
throw new Exception("foo")

tests/debug/eval-fields.check

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
break Test$ 4
2+
eval a.a1
3+
result a.a1
4+
eval a.B.b1
5+
result a.B.b1
6+
eval new A("aa", 2).a1
7+
result aa.a1
8+
eval new A("aa", 2).B.b1
9+
result aa.B.b1
10+
11+
break A 17
12+
eval name
13+
result a
14+
eval this.n
15+
result 1
16+
eval a2
17+
result a.a2
18+
eval new A("aa", 2).a2
19+
result aa.a2
20+
eval B.b1
21+
result a.B.b1
22+
eval C.c1
23+
result a.C.c1
24+
eval new A("aa", 2).C.c1
25+
result aa.C.c1

tests/debug/eval-fields.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
object Test:
2+
def main(args: Array[String]): Unit =
3+
val a = new A("a", 1)
4+
println(a)
5+
6+
class A(name: String, val n: Int):
7+
val a1 = s"$name.a1"
8+
private val a2 = s"$name.a2"
9+
10+
object B:
11+
val b1 = s"$name.B.b1"
12+
13+
private object C:
14+
val c1 = s"$name.C.c1"
15+
16+
override def toString: String =
17+
name + a2

tests/debug/eval-inner-class.check

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
break Test$ 4
2+
eval a1
3+
result A
4+
eval a2(new A)
5+
result a2
6+
eval a1.a3
7+
result a3
8+
eval (new A).a3("foo")
9+
result a3(foo)
10+
eval new test.B
11+
result B
12+
eval test.b2(test.b1)
13+
result b2
14+
eval test.b1.b3
15+
result b3
16+
eval (new test.B).b3("foo")
17+
result b3(foo)
18+
19+
break Test 17
20+
eval new B
21+
result B
22+
eval b2(new this.B)
23+
result b2
24+
eval (new B).b3
25+
result b3
26+
eval b1.b3("foo")
27+
result b3(foo)

tests/debug/eval-inner-class.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
object Test:
2+
def main(args: Array[String]): Unit =
3+
val test = new Test
4+
test.m()
5+
6+
private def a1: A = new A
7+
private def a2(a: A): String = "a2"
8+
9+
class A:
10+
val a3: String = "a3"
11+
def a3(x: String): String = s"a3($x)"
12+
override def toString: String = "A"
13+
end Test
14+
15+
class Test:
16+
def m(): Unit =
17+
println("test.m()")
18+
19+
private def b1: B = new B
20+
private def b2(b: B) = "b2"
21+
22+
private class B:
23+
val b3: String = "b3"
24+
def b3(x: String): String = s"b3($x)"
25+
override def toString: String = "B"

0 commit comments

Comments
 (0)