aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-02-13 15:01:03 +0100
committerGitHub <noreply@github.com>2017-02-13 15:01:03 +0100
commit07b67a8416c501d7f7b37442f3a294d9f9252895 (patch)
tree098772eb9ae3e5a64993e1b172505035c9b887ac /tests
parent5bcbad29a368bf6a06230aed73488995e733d97a (diff)
parent1489eff397482fec14e5da54e4654278a5c6f7dc (diff)
downloaddotty-07b67a8416c501d7f7b37442f3a294d9f9252895.tar.gz
dotty-07b67a8416c501d7f7b37442f3a294d9f9252895.tar.bz2
dotty-07b67a8416c501d7f7b37442f3a294d9f9252895.zip
Merge pull request #1951 from dotty-staging/fix-1484
fix #1484: position of while incorrect in debug
Diffstat (limited to 'tests')
-rw-r--r--tests/debug/for.scala16
-rw-r--r--tests/debug/function.scala14
-rw-r--r--tests/debug/if.scala20
-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
-rw-r--r--tests/debug/while.scala14
8 files changed, 121 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/if.scala b/tests/debug/if.scala
new file mode 100644
index 000000000..af598c1cd
--- /dev/null
+++ b/tests/debug/if.scala
@@ -0,0 +1,20 @@
+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: if]
+
+ if (a * 8 > 20) // [step: 9 * 9]
+ a = 9 * 9 // [step: if]
+ else
+ a = 34 * 23
+
+ if (a * 8 < 20) // [step: 34 * 23]
+ a = 9 * 9
+ else
+ a = 34 * 23 // [step: print]
+
+ print(a)
+ }
+}
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
diff --git a/tests/debug/while.scala b/tests/debug/while.scala
new file mode 100644
index 000000000..0e5f8f8b0
--- /dev/null
+++ b/tests/debug/while.scala
@@ -0,0 +1,14 @@
+object Test {
+
+ def main(args: Array[String]): Unit = {
+ var a = 1 + 2
+ a = a + 3
+ a = 4 + 5 // [break] [step: while]
+
+ while (a * 8 < 100) { // [step: a += 1]
+ a += 1 // [step: while] [cont: print]
+ }
+
+ print(a) // [break] [cont]
+ }
+}