summaryrefslogtreecommitdiff
path: root/test/files/run/exceptions-nest.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2010-06-02 09:57:41 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2010-06-02 09:57:41 +0000
commit2eab8f31341d787a29a7329f40ffc870f5ab594c (patch)
tree69bcc88b4fd98e70ce4c0f29415174842acb81d6 /test/files/run/exceptions-nest.scala
parentf3d87c08f6bcdb864e6990194668ad6dc16826a9 (diff)
downloadscala-2eab8f31341d787a29a7329f40ffc870f5ab594c.tar.gz
scala-2eab8f31341d787a29a7329f40ffc870f5ab594c.tar.bz2
scala-2eab8f31341d787a29a7329f40ffc870f5ab594c.zip
some tests. no review
Diffstat (limited to 'test/files/run/exceptions-nest.scala')
-rw-r--r--test/files/run/exceptions-nest.scala139
1 files changed, 139 insertions, 0 deletions
diff --git a/test/files/run/exceptions-nest.scala b/test/files/run/exceptions-nest.scala
new file mode 100644
index 0000000000..40b00988e4
--- /dev/null
+++ b/test/files/run/exceptions-nest.scala
@@ -0,0 +1,139 @@
+object Test extends Application {
+
+ println(test1)
+ println(test2)
+ println(test3)
+ println(test4)
+ println(test5)
+ try { println(test6) } catch { case _ => println("OK") }
+ println(test7)
+ try { println(test8) } catch { case _ => println("OK") }
+ println(test9)
+ println(test10)
+ println(test11)
+
+ def test1 = {
+ var x = 1
+ try {
+ x = 2
+ } catch {
+ case _: NullPointerException => x = 3
+ case _ => x = 4
+ }
+ x
+ }
+
+ def test2 = {
+ var x = 1
+ try {
+ x = 2
+ try {
+ x = 21
+ } catch {
+ case _ => x = 22
+ }
+ x = 23
+ } catch {
+ case _: NullPointerException => x = 3
+ case _ => x = 4
+ }
+ x
+ }
+
+ def test3 = {
+ var x = 1
+ try {
+ try{x = 2} catch { case _ => x = 4 }
+ } catch {
+ case _: NullPointerException => x = 3
+ case _ => x = 4
+ }
+ x
+ }
+
+ def test4 = {
+ var x = 1
+ try {
+ x = 2
+ } catch {
+ case _: NullPointerException => x = 3
+ case _ => x = 4
+ }
+ try {
+ x = 5
+ } catch {
+ case _: NullPointerException => x = 6
+ }
+ x
+ }
+
+ def test5 = {
+ var x = 1
+ try {
+ x = 2
+ } catch {
+ case _: NullPointerException => try { x = 3 } catch { case f => throw f }
+ case _ => x = 4; try { x = 41 } catch { case _: Exception => x = 42 }; x = 43
+ }
+ x
+ }
+
+ def test6: Int = {
+ var x = 1
+ try {
+ x = 2
+ (null: String).toString
+ } catch {
+ case e: NullPointerException =>
+ throw e
+ case _ =>
+ x = 3
+ return 1000
+ } finally {
+ x = 4
+ println(x)
+ }
+ x
+ }
+
+ def test7 = {
+ var x = 1
+ try {
+ x = 2
+ } finally {
+ try {
+ x = 4
+ } catch {
+ case _ => x = 5
+ }
+ }
+ x
+ }
+
+ def test8 = {
+ var x = 1
+ try {
+ throw new NullPointerException
+ } catch {
+ case e => throw e
+ }
+ x
+ }
+
+ def test9 = {
+ try { "" match {
+ case s: String => 10
+ }} catch { case _ => 20 }
+ }
+
+ var x10 = 1
+ def test10: Int = {
+ try { 1 }
+ catch { case e if (x10 == 1) => 1 }
+ }
+
+ def test11 {
+ try { () }
+ catch { case e => () }
+ }
+}