diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2006-01-30 10:15:18 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2006-01-30 10:15:18 +0000 |
commit | 3ebac4319b2ec21de7de1c3d228c370ea0e4675b (patch) | |
tree | 2976801fde5a2c954dc4966f97ec45a1b2370744 /test/files/run/try-2.scala | |
parent | 60a0f3e591711a407a2f155b0b0341c509707213 (diff) | |
download | scala-3ebac4319b2ec21de7de1c3d228c370ea0e4675b.tar.gz scala-3ebac4319b2ec21de7de1c3d228c370ea0e4675b.tar.bz2 scala-3ebac4319b2ec21de7de1c3d228c370ea0e4675b.zip |
Added more test files for try-catch blocks.
Diffstat (limited to 'test/files/run/try-2.scala')
-rw-r--r-- | test/files/run/try-2.scala | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/files/run/try-2.scala b/test/files/run/try-2.scala new file mode 100644 index 0000000000..747f81e0ce --- /dev/null +++ b/test/files/run/try-2.scala @@ -0,0 +1,62 @@ +/* + * Test different variants of the try-catch block. + * + * $Id: $ + */ + + +object Test { + + + def tryAllUnit: Unit = + try { + throw new Error(); + } + catch { + case _ => Console.println("exception happened\n"); + } + + def tryUnitAll: Unit = + try { + Console.println("Nothin"); + } catch { + case _ => error("Bad, bad, lama!"); + } + + def tryAllAll: Unit = + try { + throw new Error(); + } catch { + case _ => error("Bad, bad, lama!"); + } + + def tryUnitUnit: Unit = + try { + Console.println("Nothin"); + } catch { + case _ => Console.println("Nothin"); + } + + def tryIntUnit: Unit = + try { + 10; + } catch { + case _ => Console.println("Huh?"); + } + + + def execute(f: => Unit) = try { + f; + } catch { + case _ => (); + } + + + def main(args:Array[String]): Unit = { + execute(tryAllUnit); + execute(tryUnitAll); + execute(tryAllAll); + execute(tryUnitUnit); + execute(tryIntUnit); + } +} |