summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2006-05-19 14:55:15 +0000
committerIulian Dragos <jaguarul@gmail.com>2006-05-19 14:55:15 +0000
commitef2de304b1cafdf7bc4f0230f73ed084455fa450 (patch)
treec8d6717966d3c4c955201cc9c591648776bfc7c4 /test/files/run
parentf746ce36d86a08c8456f5fae04459addcdd2c62d (diff)
downloadscala-ef2de304b1cafdf7bc4f0230f73ed084455fa450.tar.gz
scala-ef2de304b1cafdf7bc4f0230f73ed084455fa450.tar.bz2
scala-ef2de304b1cafdf7bc4f0230f73ed084455fa450.zip
Fixed two try-finally bugs.
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/exceptions-2.check14
-rw-r--r--test/files/run/exceptions-2.scala39
2 files changed, 48 insertions, 5 deletions
diff --git a/test/files/run/exceptions-2.check b/test/files/run/exceptions-2.check
index 3ec0dfcc1c..e67f147506 100644
--- a/test/files/run/exceptions-2.check
+++ b/test/files/run/exceptions-2.check
@@ -17,11 +17,17 @@ method3:
Exception occurred with stack trace:
java.lang.NullPointerException
at Test$.method3(exceptions-2.scala:108)
- at Test$$anonfun$5.apply(exceptions-2.scala:151)
- at Test$$anonfun$5.apply(exceptions-2.scala:151)
- at Test$.execute(exceptions-2.scala:128)
- at Test$.main(exceptions-2.scala:151)
+ at Test$$anonfun$5.apply(exceptions-2.scala:180)
+ at Test$$anonfun$5.apply(exceptions-2.scala:180)
+ at Test$.execute(exceptions-2.scala:157)
+ at Test$.main(exceptions-2.scala:180)
at Test.main(exceptions-2.scala)
+tryFinallyTry:
+Silently ignore exception in finally
+valInFinally:
+Abc
+tryAndValInFinally
+Abc
=================
NoExcep.method2:
Hello, world
diff --git a/test/files/run/exceptions-2.scala b/test/files/run/exceptions-2.scala
index 2583542747..e006bc053d 100644
--- a/test/files/run/exceptions-2.scala
+++ b/test/files/run/exceptions-2.scala
@@ -1,7 +1,7 @@
/*
* Try exception handling and finally blocks.
*
- * $Id: $
+ * $Id$
*/
@@ -124,6 +124,35 @@ object Test {
Console.println(x);
}
+ def tryFinallyTry: Unit = {
+ try {
+ ()
+ } finally {
+ try {
+ error("a");
+ } catch {
+ case _ => Console.println("Silently ignore exception in finally");
+ }
+ }
+ }
+
+ def valInFinally: Unit =
+ try {
+ } finally {
+ val fin = "Abc";
+ Console.println(fin);
+ };
+
+ def tryAndValInFinally: Unit =
+ try {
+ } finally {
+ val fin = "Abc";
+ try {
+ Console.println(fin);
+ } catch { case _ => () }
+ };
+
+
def execute(f: => Unit) = try {
f;
} catch {
@@ -150,6 +179,14 @@ object Test {
Console.println("method3:");
execute(method3);
+ Console.println("tryFinallyTry:");
+ execute(tryFinallyTry);
+
+ Console.println("valInFinally:");
+ execute(valInFinally);
+ Console.println("tryAndValInFinally");
+ execute(tryAndValInFinally);
+
Console.println("=================");
Console.println("NoExcep.method2:");