From b22342e78a3134d186f82dac5e1c7be01ece7c17 Mon Sep 17 00:00:00 2001 From: Philipp Haller Date: Wed, 27 May 2009 15:59:21 +0000 Subject: Added tests for #2015. --- test/files/jvm/actor-termination.check | 2 ++ test/files/jvm/actor-termination.scala | 13 +++++++++++++ test/files/jvm/daemon-actor-termination.check | 2 ++ test/files/jvm/daemon-actor-termination.scala | 19 +++++++++++++++++++ test/files/jvm/future-termination.check | 1 + test/files/jvm/future-termination.scala | 14 ++++++++++++++ 6 files changed, 51 insertions(+) create mode 100644 test/files/jvm/actor-termination.check create mode 100644 test/files/jvm/actor-termination.scala create mode 100644 test/files/jvm/daemon-actor-termination.check create mode 100644 test/files/jvm/daemon-actor-termination.scala create mode 100644 test/files/jvm/future-termination.check create mode 100644 test/files/jvm/future-termination.scala (limited to 'test') diff --git a/test/files/jvm/actor-termination.check b/test/files/jvm/actor-termination.check new file mode 100644 index 0000000000..e3f44d8b18 --- /dev/null +++ b/test/files/jvm/actor-termination.check @@ -0,0 +1,2 @@ +I'm going to make you wait. +Ok, I'm done. diff --git a/test/files/jvm/actor-termination.scala b/test/files/jvm/actor-termination.scala new file mode 100644 index 0000000000..19dfaf8e17 --- /dev/null +++ b/test/files/jvm/actor-termination.scala @@ -0,0 +1,13 @@ +import scala.actors.Actor + +/* Test that an actor that hasn't finished prevents termination */ + +object Test { + def main(args: Array[String]) { + Actor.actor { + println("I'm going to make you wait.") + Thread.sleep(5000) + println("Ok, I'm done.") + } + } +} diff --git a/test/files/jvm/daemon-actor-termination.check b/test/files/jvm/daemon-actor-termination.check new file mode 100644 index 0000000000..22cb38fd7d --- /dev/null +++ b/test/files/jvm/daemon-actor-termination.check @@ -0,0 +1,2 @@ +I'm going to make you wait. +I'm tired of waiting for you. Good bye. diff --git a/test/files/jvm/daemon-actor-termination.scala b/test/files/jvm/daemon-actor-termination.scala new file mode 100644 index 0000000000..322efbe212 --- /dev/null +++ b/test/files/jvm/daemon-actor-termination.scala @@ -0,0 +1,19 @@ +import scala.actors.DaemonActor + +/* Test that a DaemonActor that hasn't finished does not prevent termination */ + +object Test { + class MyDaemon extends DaemonActor { + def act() { + println("I'm going to make you wait.") + Thread.sleep(5000) + println("Ok, I'm done.") + } + } + def main(args: Array[String]) { + val daemon = new MyDaemon + daemon.start() + Thread.sleep(500) // give the daemon a chance to start + println("I'm tired of waiting for you. Good bye.") + } +} diff --git a/test/files/jvm/future-termination.check b/test/files/jvm/future-termination.check new file mode 100644 index 0000000000..dc335465d4 --- /dev/null +++ b/test/files/jvm/future-termination.check @@ -0,0 +1 @@ +I can't wait that long, bye. diff --git a/test/files/jvm/future-termination.scala b/test/files/jvm/future-termination.scala new file mode 100644 index 0000000000..c448a88aa7 --- /dev/null +++ b/test/files/jvm/future-termination.scala @@ -0,0 +1,14 @@ +import scala.actors.Futures + +/* Test that unevaluated futures do not prevent program termination */ + +object Test { + def main(args: Array[String]) { + val meaningOfLife = Futures.future { + Thread.sleep(5000) // pretend this is a harder problem than it is + println("I have the answer!") + 42 + } + println("I can't wait that long, bye.") + } +} -- cgit v1.2.3