#3457 - Adding proper type to TestFsmRef
This commit is contained in:
parent
981bce5dd0
commit
f333c7c345
2 changed files with 15 additions and 14 deletions
|
|
@ -5,18 +5,15 @@ package docs.testkit
|
||||||
|
|
||||||
import language.postfixOps
|
import language.postfixOps
|
||||||
import scala.util.Success
|
import scala.util.Success
|
||||||
|
import akka.testkit._
|
||||||
|
|
||||||
//#imports-test-probe
|
//#imports-test-probe
|
||||||
import akka.testkit.TestProbe
|
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import akka.actor._
|
import akka.actor._
|
||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
|
|
||||||
//#imports-test-probe
|
//#imports-test-probe
|
||||||
|
|
||||||
import akka.testkit.AkkaSpec
|
|
||||||
import akka.testkit.DefaultTimeout
|
|
||||||
import akka.testkit.ImplicitSender
|
|
||||||
import scala.util.control.NonFatal
|
import scala.util.control.NonFatal
|
||||||
|
|
||||||
object TestkitDocSpec {
|
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
|
//#my-double-echo
|
||||||
class MyDoubleEcho extends Actor {
|
class MyDoubleEcho extends Actor {
|
||||||
var dest1: ActorRef = _
|
var dest1: ActorRef = _
|
||||||
|
|
@ -91,15 +98,9 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
||||||
import akka.actor.FSM
|
import akka.actor.FSM
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
val fsm = TestFSMRef(new Actor with FSM[Int, String] {
|
val fsm = TestFSMRef(new TestFsmActor)
|
||||||
startWith(1, "")
|
|
||||||
when(1) {
|
val mustBeTypedProperly: TestActorRef[TestFsmActor] = fsm
|
||||||
case Event("go", _) ⇒ goto(2) using "go"
|
|
||||||
}
|
|
||||||
when(2) {
|
|
||||||
case Event("back", _) ⇒ goto(1) using "back"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
assert(fsm.stateName == 1)
|
assert(fsm.stateName == 1)
|
||||||
assert(fsm.stateData == "")
|
assert(fsm.stateData == "")
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class TestFSMRef[S, D, T <: Actor](
|
||||||
props: Props,
|
props: Props,
|
||||||
supervisor: ActorRef,
|
supervisor: ActorRef,
|
||||||
name: String)(implicit ev: T <:< FSM[S, D])
|
name: String)(implicit ev: T <:< FSM[S, D])
|
||||||
extends TestActorRef(system, props, supervisor, name) {
|
extends TestActorRef[T](system, props, supervisor, name) {
|
||||||
|
|
||||||
private def fsm: T = underlyingActor
|
private def fsm: T = underlyingActor
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue