From c7a557c43221c1fbad4117e63b6cd8c255ddc8f7 Mon Sep 17 00:00:00 2001 From: liu fengyun Date: Thu, 9 Feb 2017 17:24:47 +0100 Subject: add more debug files to the tests --- tests/debug/for.scala | 16 ++++++++++++++++ tests/debug/function.scala | 14 ++++++++++++++ tests/debug/method.scala | 14 ++++++++++++++ tests/debug/nested-method.scala | 15 +++++++++++++++ tests/debug/sequence.scala | 11 +++++++++++ tests/debug/tailrec.scala | 17 +++++++++++++++++ 6 files changed, 87 insertions(+) create mode 100644 tests/debug/for.scala create mode 100644 tests/debug/function.scala create mode 100644 tests/debug/method.scala create mode 100644 tests/debug/nested-method.scala create mode 100644 tests/debug/sequence.scala create mode 100644 tests/debug/tailrec.scala (limited to 'tests') 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 -- cgit v1.2.3