aboutsummaryrefslogtreecommitdiff
path: root/tests/run/liftedTry.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/liftedTry.scala')
-rw-r--r--tests/run/liftedTry.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/run/liftedTry.scala b/tests/run/liftedTry.scala
new file mode 100644
index 000000000..2e4c25c2b
--- /dev/null
+++ b/tests/run/liftedTry.scala
@@ -0,0 +1,21 @@
+object Test {
+
+ def raise(x: Int) = { throw new Exception(s"$x"); 0 }
+ def handle: Throwable => Int = { case ex: Exception => ex.getMessage().toInt }
+
+ val x = try raise(1) catch handle
+
+ def foo(x: Int) = {
+ val y = try raise(x) catch handle
+ y
+ }
+
+ foo(try 3 catch handle)
+
+ def main(args: Array[String]) = {
+ assert(x == 1)
+ assert(foo(2) == 2)
+ assert(foo(try raise(3) catch handle) == 3)
+ }
+}
+