From 0708b61d19f1d69f4017d0f4a5778ed805c0922b Mon Sep 17 00:00:00 2001 From: Philipp Haller Date: Tue, 9 Mar 2010 10:35:13 +0000 Subject: Made actor-getstate test more robust. No review. --- test/files/jvm/actor-getstate.scala | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/files/jvm/actor-getstate.scala b/test/files/jvm/actor-getstate.scala index 9de3247653..8d2ee0ae3c 100644 --- a/test/files/jvm/actor-getstate.scala +++ b/test/files/jvm/actor-getstate.scala @@ -2,34 +2,34 @@ import scala.actors.{Reactor, Actor, TIMEOUT} object Test { - def assert(cond: => Boolean) { + def assert(cond: => Boolean, hint: String) { if (!cond) - println("FAIL") + println("FAIL ["+hint+"]") } def main(args: Array[String]) { val a = new Reactor[Any] { def act() { - assert(getState == Actor.State.Runnable) + assert(getState == Actor.State.Runnable, "runnable1") react { case 'go => println("OK") } } } - assert(a.getState == Actor.State.New) + assert(a.getState == Actor.State.New, "new1") a.start() - Thread.sleep(100) - assert(a.getState == Actor.State.Suspended) + Thread.sleep(200) + assert(a.getState == Actor.State.Suspended, "suspend1") a ! 'go - Thread.sleep(100) - assert(a.getState == Actor.State.Terminated) + Thread.sleep(200) + assert(a.getState == Actor.State.Terminated, "terminated1") val b = new Actor { def act() { - assert(getState == Actor.State.Runnable) + assert(getState == Actor.State.Runnable, "runnable2") react { case 'go => reactWithin(100000) { @@ -47,27 +47,27 @@ object Test { } } } - assert(b.getState == Actor.State.New) + assert(b.getState == Actor.State.New, "new2") b.start() - Thread.sleep(100) - assert(b.getState == Actor.State.Suspended) + Thread.sleep(200) + assert(b.getState == Actor.State.Suspended, "suspend2") b ! 'go - Thread.sleep(100) - assert(b.getState == Actor.State.TimedSuspended) + Thread.sleep(200) + assert(b.getState == Actor.State.TimedSuspended, "timedsuspend2") b ! 'go - Thread.sleep(100) - assert(b.getState == Actor.State.Blocked) + Thread.sleep(200) + assert(b.getState == Actor.State.Blocked, "blocked2") b ! 'go - Thread.sleep(100) - assert(b.getState == Actor.State.TimedBlocked) + Thread.sleep(200) + assert(b.getState == Actor.State.TimedBlocked, "timedblocked2") b ! 'go - Thread.sleep(100) - assert(b.getState == Actor.State.Terminated) + Thread.sleep(200) + assert(b.getState == Actor.State.Terminated, "terminated2") } } -- cgit v1.2.3