From 08496424f2df9baf9d3612ed2f1bdb2553e7bfd6 Mon Sep 17 00:00:00 2001 From: Philipp Haller Date: Mon, 12 Apr 2010 12:02:51 +0000 Subject: Another test for see #2017. No review. --- test/files/jvm/actor-uncaught-exception2.check | 2 ++ test/files/jvm/actor-uncaught-exception2.scala | 48 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/files/jvm/actor-uncaught-exception2.check create mode 100644 test/files/jvm/actor-uncaught-exception2.scala diff --git a/test/files/jvm/actor-uncaught-exception2.check b/test/files/jvm/actor-uncaught-exception2.check new file mode 100644 index 0000000000..870a5d32f9 --- /dev/null +++ b/test/files/jvm/actor-uncaught-exception2.check @@ -0,0 +1,2 @@ +UncaughtException(StartError,None,None,MyException: I don't want to run!) +UncaughtException(MessageError,Some('ping),Some(Supervisor),MyException: No message for me!) diff --git a/test/files/jvm/actor-uncaught-exception2.scala b/test/files/jvm/actor-uncaught-exception2.scala new file mode 100644 index 0000000000..973cfb370a --- /dev/null +++ b/test/files/jvm/actor-uncaught-exception2.scala @@ -0,0 +1,48 @@ +import scala.actors.{Actor, Exit, Debug} + +class MyException(msg: String) extends Exception(msg) { + override def fillInStackTrace() = this +} + +object Test { + + case object StartError extends Actor { + def act() { + throw new MyException("I don't want to run!") + } + } + + case object MessageError extends Actor { + def act() { + react { + case _ => throw new MyException("No message for me!") + } + } + } + + case object Supervisor extends Actor { + def act() { + trapExit = true + link(StartError) + link(MessageError) + StartError.start() + MessageError.start() + + Actor.loop { + react { + case Exit(actor, reason) => + println(reason) + if (actor == StartError) + MessageError ! 'ping + else + exit() + } + } + } + } + + def main(args: Array[String]) { + Debug.level = 1 // decrease level so that it does not print warnings + Supervisor.start() + } +} -- cgit v1.2.3