diff options
author | Philipp Haller <hallerp@gmail.com> | 2009-05-31 13:20:43 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2009-05-31 13:20:43 +0000 |
commit | 8c23908ebb28540e89d3eec8ef699d6af55c3d55 (patch) | |
tree | c85f2c566330a996b940e16a2013530952fba9c9 /test/files/jvm/actor-receivewithin.scala | |
parent | 63031aa7f0f1f32c7b998d118c832cb181b4e99e (diff) | |
download | scala-8c23908ebb28540e89d3eec8ef699d6af55c3d55.tar.gz scala-8c23908ebb28540e89d3eec8ef699d6af55c3d55.tar.bz2 scala-8c23908ebb28540e89d3eec8ef699d6af55c3d55.zip |
New tests for exceptions and Actor.receiveWithin.
Diffstat (limited to 'test/files/jvm/actor-receivewithin.scala')
-rw-r--r-- | test/files/jvm/actor-receivewithin.scala | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/files/jvm/actor-receivewithin.scala b/test/files/jvm/actor-receivewithin.scala new file mode 100644 index 0000000000..c6818cf211 --- /dev/null +++ b/test/files/jvm/actor-receivewithin.scala @@ -0,0 +1,67 @@ +import scala.actors.{Actor, TIMEOUT} + +object A extends Actor { + def act() { + receive { + case 'done => + var cnt = 0 + while (cnt < 500) { + cnt += 1 + receiveWithin (0) { + case 'msg => + if (cnt % 100 == 0) + println("'msg") + case TIMEOUT => + // should not happen + println("FAIL1") + } + } + cnt = 0 + while (cnt < 500) { + cnt += 1 + receiveWithin (0) { + case 'msg => + // should not happen + println("FAIL2") + case TIMEOUT => + if (cnt % 100 == 0) + println("TIMEOUT") + } + } + B ! 'next + cnt = 0 + while (cnt < 501) { + cnt += 1 + receiveWithin (500) { + case 'msg2 => + if (cnt % 100 == 0) + println("'msg2") + case TIMEOUT => + println("TIMEOUT") + } + } + } + } +} + +object B extends Actor { + def act() { + A.start() + for (_ <- 1 to 500) { + A ! 'msg + } + A ! 'done + receive { + case 'next => + for (_ <- 1 to 500) { + A ! 'msg2 + } + } + } +} + +object Test { + def main(args:Array[String]) { + B.start() + } +} |