summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/continuations-neg/trycatch2.check7
-rw-r--r--test/files/continuations-neg/trycatch2.scala33
-rw-r--r--test/files/continuations-run/trycatch0.check2
-rw-r--r--test/files/continuations-run/trycatch0.scala25
-rw-r--r--test/files/continuations-run/trycatch1.check4
-rw-r--r--test/files/continuations-run/trycatch1.scala48
6 files changed, 119 insertions, 0 deletions
diff --git a/test/files/continuations-neg/trycatch2.check b/test/files/continuations-neg/trycatch2.check
new file mode 100644
index 0000000000..5ff2838bad
--- /dev/null
+++ b/test/files/continuations-neg/trycatch2.check
@@ -0,0 +1,7 @@
+trycatch2.scala:11: error: only simple cps types allowed in try/catch blocks (found: Int @scala.util.continuations.cpsParam[String,Int])
+ def foo1 = try {
+ ^
+trycatch2.scala:19: error: only simple cps types allowed in try/catch blocks (found: Int @scala.util.continuations.cpsParam[String,Int])
+ def foo2 = try {
+ ^
+two errors found
diff --git a/test/files/continuations-neg/trycatch2.scala b/test/files/continuations-neg/trycatch2.scala
new file mode 100644
index 0000000000..761cee52ac
--- /dev/null
+++ b/test/files/continuations-neg/trycatch2.scala
@@ -0,0 +1,33 @@
+// $Id$
+
+import scala.util.continuations._
+
+object Test {
+
+ def fatal[T]: T = throw new Exception
+ def cpsIntStringInt = shift { k:(Int=>String) => k(3); 7 }
+ def cpsIntIntString = shift { k:(Int=>Int) => k(3); "7" }
+
+ def foo1 = try {
+ fatal[Int]
+ cpsIntStringInt
+ } catch {
+ case ex =>
+ cpsIntStringInt
+ }
+
+ def foo2 = try {
+ fatal[Int]
+ cpsIntStringInt
+ } catch {
+ case ex =>
+ cpsIntStringInt
+ }
+
+
+ def main(args: Array[String]): Unit = {
+ println(reset { foo1; "3" })
+ println(reset { foo2; "3" })
+ }
+
+} \ No newline at end of file
diff --git a/test/files/continuations-run/trycatch0.check b/test/files/continuations-run/trycatch0.check
new file mode 100644
index 0000000000..36806909d0
--- /dev/null
+++ b/test/files/continuations-run/trycatch0.check
@@ -0,0 +1,2 @@
+10
+10 \ No newline at end of file
diff --git a/test/files/continuations-run/trycatch0.scala b/test/files/continuations-run/trycatch0.scala
new file mode 100644
index 0000000000..74a078b5ef
--- /dev/null
+++ b/test/files/continuations-run/trycatch0.scala
@@ -0,0 +1,25 @@
+// $Id$
+
+import scala.util.continuations._
+
+object Test {
+
+ def foo = try {
+ shift((k: Int=>Int) => k(7))
+ } catch {
+ case ex =>
+ 9
+ }
+
+ def bar = try {
+ 7
+ } catch {
+ case ex =>
+ shiftUnit0[Int,Int](9)
+ }
+
+ def main(args: Array[String]): Unit = {
+ println(reset { foo + 3 })
+ println(reset { bar + 3 })
+ }
+} \ No newline at end of file
diff --git a/test/files/continuations-run/trycatch1.check b/test/files/continuations-run/trycatch1.check
new file mode 100644
index 0000000000..a028d2b1e1
--- /dev/null
+++ b/test/files/continuations-run/trycatch1.check
@@ -0,0 +1,4 @@
+12
+12
+12
+12 \ No newline at end of file
diff --git a/test/files/continuations-run/trycatch1.scala b/test/files/continuations-run/trycatch1.scala
new file mode 100644
index 0000000000..ade13794e3
--- /dev/null
+++ b/test/files/continuations-run/trycatch1.scala
@@ -0,0 +1,48 @@
+// $Id$
+
+import scala.util.continuations._
+
+object Test {
+
+ def fatal: Int = throw new Exception()
+
+ def foo1 = try {
+ fatal
+ shift((k: Int=>Int) => k(7))
+ } catch {
+ case ex =>
+ 9
+ }
+
+ def foo2 = try {
+ shift((k: Int=>Int) => k(7))
+ fatal
+ } catch {
+ case ex =>
+ 9
+ }
+
+ def bar1 = try {
+ fatal
+ 7
+ } catch {
+ case ex =>
+ shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner
+ }
+
+ def bar2 = try {
+ 7
+ fatal
+ } catch {
+ case ex =>
+ shiftUnit0[Int,Int](9) // regular shift causes no-symbol doesn't have owner
+ }
+
+ def main(args: Array[String]): Unit = {
+ println(reset { foo1 + 3 })
+ println(reset { foo2 + 3 })
+ println(reset { bar1 + 3 })
+ println(reset { bar2 + 3 })
+ }
+
+} \ No newline at end of file