Skip to content

Commit 857f53e

Browse files
committed
Add more tests
1 parent 2837365 commit 857f53e

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
lines changed

tests/run/i4947.check

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
failed
2-
Test$.main(i4947.scala:9)
1+
track: Test$.main(i4947.scala:14)
2+
track: Test$.main(i4947.scala:14)
3+
main1: Test$.main(i4947.scala:15)
4+
main2: Test$.main(i4947.scala:16)

tests/run/i4947.scala

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
object Test {
22

3-
transparent def track[T](f: => T): T = f
3+
transparent def track[T](f: => T): T = {
4+
printStack("track")
5+
printStack("track")
6+
f
7+
}
8+
9+
def printStack(tag: String): Unit = {
10+
println(tag + ": "+ new Exception().getStackTrace().apply(1))
11+
}
412

513
def main(args: Array[String]): Unit = {
6-
try {
7-
track {
8-
val a = 9
9-
throw new Exception("failed")
10-
}
11-
} catch {
12-
case ex: Throwable =>
13-
println(ex.getMessage)
14-
println(ex.getStackTrace.head)
14+
track {
15+
printStack("main1")
16+
printStack("main2")
1517
}
1618
}
1719

tests/run/i4947b.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
track: Test$.main(Test_2.scala:3)
2+
track: Test$.main(Test_2.scala:3)
3+
main1: Test$.main(Test_2.scala:4)
4+
main2: Test$.main(Test_2.scala:5)

tests/run/i4947b/Lib_1.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object Lib {
2+
transparent def track[T](f: => T): T = {
3+
printStack("track")
4+
printStack("track")
5+
f
6+
}
7+
def printStack(tag: String): Unit = {
8+
println(tag + ": "+ new Exception().getStackTrace().apply(1))
9+
}
10+
}

tests/run/i4947b/Test_2.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
Lib.track {
4+
Lib.printStack("main1")
5+
Lib.printStack("main2")
6+
}
7+
}
8+
9+
}

0 commit comments

Comments
 (0)