aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/debug/for.scala16
-rw-r--r--tests/debug/function.scala14
-rw-r--r--tests/debug/method.scala14
-rw-r--r--tests/debug/nested-method.scala15
-rw-r--r--tests/debug/sequence.scala11
-rw-r--r--tests/debug/tailrec.scala17
6 files changed, 87 insertions, 0 deletions
diff --git a/tests/debug/for.scala b/tests/debug/for.scala
new file mode 100644
index 000000000..b2287a988
--- /dev/null
+++ b/tests/debug/for.scala
@@ -0,0 +1,16 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ val b = 8 * 9 // [break] [step: f()]
+ f() // [step: val a]
+ 20 + b
+ print(b)
+ }
+
+ def f(): Unit = {
+ val a = for (i <- 1 to 5; j <- 10 to 20) // [cont]
+ yield (i, j) // Error: incorrect reaching this line
+
+ for (i <- 1 to 5; j <- 10 to 20)
+ println(i + j) // TODO: i is renamed to i$2 --> reduce debuggability
+ }
+} \ No newline at end of file
diff --git a/tests/debug/function.scala b/tests/debug/function.scala
new file mode 100644
index 000000000..644344414
--- /dev/null
+++ b/tests/debug/function.scala
@@ -0,0 +1,14 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ val a = 1 + 2
+ val b = a * 9 // [break] [step: plus] [step: c = plus]
+ val plus = (x: Int, y: Int) => { // [cont: x * x]
+ val a = x * x // [break] [step: y * y]
+ val b = y * y // [step: a + b]
+ a + b // [next] [next]
+ }
+ val c = plus(a, b) // [next: print]
+ print(c) // [cont]
+ }
+
+}
diff --git a/tests/debug/method.scala b/tests/debug/method.scala
new file mode 100644
index 000000000..9489b0088
--- /dev/null
+++ b/tests/debug/method.scala
@@ -0,0 +1,14 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ val a = 1 + 2 // [break] [step: a * 9]
+ val b = a * 9 // [step: plus]
+ val c = plus(a, b) // [step: x * x]
+ print(c)
+ }
+
+ def plus(x: Int, y: Int) = {
+ val a = x * x // [step: y * y]
+ val b = y * y // [step: a + b]
+ a + b // [step: plus] [step: print] [cont]
+ }
+}
diff --git a/tests/debug/nested-method.scala b/tests/debug/nested-method.scala
new file mode 100644
index 000000000..fcc326ccb
--- /dev/null
+++ b/tests/debug/nested-method.scala
@@ -0,0 +1,15 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ val a = 1 + 2 // [break] [step: a * 9]
+ val b = a * 9 // [step: plus] [step: x * x]
+
+ def plus(x: Int, y: Int) = {
+ val a = x * x // [step: y * y]
+ val b = y * y // [step: a + b]
+ a + b // [step: plus]
+ }
+
+ val c = plus(a, b) // [step: print] [cont]
+ print(c)
+ }
+} \ No newline at end of file
diff --git a/tests/debug/sequence.scala b/tests/debug/sequence.scala
new file mode 100644
index 000000000..a6c1e9018
--- /dev/null
+++ b/tests/debug/sequence.scala
@@ -0,0 +1,11 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ var a = 1 + 2 // [break] [step: a + 3]
+ a = a + 3 // [step: 4 + 5]
+ a = 4 + 5 // [step: a * 8]
+ a = a * 8 // [step: 9 * 9]
+ a = 9 * 9 // [step: 34 * 23]
+ a = 34 * 23 // [step: print]
+ print(a) // [cont]
+ }
+} \ No newline at end of file
diff --git a/tests/debug/tailrec.scala b/tests/debug/tailrec.scala
new file mode 100644
index 000000000..f79514fa3
--- /dev/null
+++ b/tests/debug/tailrec.scala
@@ -0,0 +1,17 @@
+object Test {
+ def fact(x: Int): Int = {
+ if (x == 0)
+ 1
+ else
+ x * fact(x - 1) // TODO: incorrect this line when x = 0
+ }
+
+
+ def main(args: Array[String]): Unit = {
+ val a = 1 + 2
+ val b = a * 9 // [break] [step: fact]
+ val c = fact(a) // [step: x == 0] [step: fact(x - 1)] [step: x == 0] [cont]
+ fact(0) // [break] [step: x == 0] [step: 1] [step: fact(x - 1)] [step: print]
+ print(c) // [cont]
+ }
+} \ No newline at end of file