Merge pull request #1551 from akka/wip-3457-properly-type-TestFSMRef-√

#3457 - Adding proper type to TestFsmRef
This commit is contained in:
Roland Kuhn 2013-06-20 04:05:28 -07:00
commit 18f5b8f4ec
2 changed files with 15 additions and 14 deletions

View file

@ -5,18 +5,15 @@ package docs.testkit
import language.postfixOps
import scala.util.Success
import akka.testkit._
//#imports-test-probe
import akka.testkit.TestProbe
import scala.concurrent.duration._
import akka.actor._
import scala.concurrent.Future
//#imports-test-probe
import akka.testkit.AkkaSpec
import akka.testkit.DefaultTimeout
import akka.testkit.ImplicitSender
import scala.util.control.NonFatal
object TestkitDocSpec {
@ -30,6 +27,16 @@ object TestkitDocSpec {
}
}
class TestFsmActor extends Actor with FSM[Int, String] {
startWith(1, "")
when(1) {
case Event("go", _) goto(2) using "go"
}
when(2) {
case Event("back", _) goto(1) using "back"
}
}
//#my-double-echo
class MyDoubleEcho extends Actor {
var dest1: ActorRef = _
@ -91,15 +98,9 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
import akka.actor.FSM
import scala.concurrent.duration._
val fsm = TestFSMRef(new Actor with FSM[Int, String] {
startWith(1, "")
when(1) {
case Event("go", _) goto(2) using "go"
}
when(2) {
case Event("back", _) goto(1) using "back"
}
})
val fsm = TestFSMRef(new TestFsmActor)
val mustBeTypedProperly: TestActorRef[TestFsmActor] = fsm
assert(fsm.stateName == 1)
assert(fsm.stateData == "")