Skip to content

Commit c174659

Browse files
committed
add more debug files to the tests
1 parent 81c6b02 commit c174659

File tree

6 files changed

+87
-0
lines changed

6 files changed

+87
-0
lines changed

tests/debug/for.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
val b = 8 * 9 // [break] [step: f()]
4+
f() // [step: val a]
5+
20 + b
6+
print(b)
7+
}
8+
9+
def f(): Unit = {
10+
val a = for (i <- 1 to 5; j <- 10 to 20) // [cont]
11+
yield (i, j) // Error: incorrect reaching this line
12+
13+
for (i <- 1 to 5; j <- 10 to 20)
14+
println(i + j) // TODO: i is renamed to i$2 --> reduce debuggability
15+
}
16+
}

tests/debug/function.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
val a = 1 + 2
4+
val b = a * 9 // [break] [step: plus] [step: c = plus]
5+
val plus = (x: Int, y: Int) => { // [cont: x * x]
6+
val a = x * x // [break] [step: y * y]
7+
val b = y * y // [step: a + b]
8+
a + b // [next] [next]
9+
}
10+
val c = plus(a, b) // [next: print]
11+
print(c) // [cont]
12+
}
13+
14+
}

tests/debug/method.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
val a = 1 + 2 // [break] [step: a * 9]
4+
val b = a * 9 // [step: plus]
5+
val c = plus(a, b) // [step: x * x]
6+
print(c)
7+
}
8+
9+
def plus(x: Int, y: Int) = {
10+
val a = x * x // [step: y * y]
11+
val b = y * y // [step: a + b]
12+
a + b // [step: plus] [step: print] [cont]
13+
}
14+
}

tests/debug/nested-method.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
val a = 1 + 2 // [break] [step: a * 9]
4+
val b = a * 9 // [step: plus] [step: x * x]
5+
6+
def plus(x: Int, y: Int) = {
7+
val a = x * x // [step: y * y]
8+
val b = y * y // [step: a + b]
9+
a + b // [step: plus]
10+
}
11+
12+
val c = plus(a, b) // [step: print] [cont]
13+
print(c)
14+
}
15+
}

tests/debug/sequence.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
var a = 1 + 2 // [break] [step: a + 3]
4+
a = a + 3 // [step: 4 + 5]
5+
a = 4 + 5 // [step: a * 8]
6+
a = a * 8 // [step: 9 * 9]
7+
a = 9 * 9 // [step: 34 * 23]
8+
a = 34 * 23 // [step: print]
9+
print(a) // [cont]
10+
}
11+
}

tests/debug/tailrec.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
object Test {
2+
def fact(x: Int): Int = {
3+
if (x == 0)
4+
1
5+
else
6+
x * fact(x - 1) // TODO: incorrect this line when x = 0
7+
}
8+
9+
10+
def main(args: Array[String]): Unit = {
11+
val a = 1 + 2
12+
val b = a * 9 // [break] [step: fact]
13+
val c = fact(a) // [step: x == 0] [step: fact(x - 1)] [step: x == 0] [cont]
14+
fact(0) // [break] [step: x == 0] [step: 1] [step: fact(x - 1)] [step: print]
15+
print(c) // [cont]
16+
}
17+
}

0 commit comments

Comments
 (0)