#2661 - Changing ignoreMsg of TestProbe to take a PF from Any instead of AnyRef, to support primitives

This commit is contained in:
Viktor Klang 2012-10-29 23:07:06 +01:00
parent 3ee7dbcc45
commit d01ea366ce
2 changed files with 9 additions and 2 deletions

View file

@ -16,7 +16,7 @@ import scala.annotation.varargs
import scala.reflect.ClassTag import scala.reflect.ClassTag
object TestActor { object TestActor {
type Ignore = Option[PartialFunction[AnyRef, Boolean]] type Ignore = Option[PartialFunction[Any, Boolean]]
abstract class AutoPilot { abstract class AutoPilot {
def run(sender: ActorRef, msg: Any): AutoPilot def run(sender: ActorRef, msg: Any): AutoPilot
@ -138,7 +138,7 @@ trait TestKitBase {
* Ignore all messages in the test actor for which the given partial * Ignore all messages in the test actor for which the given partial
* function returns true. * function returns true.
*/ */
def ignoreMsg(f: PartialFunction[AnyRef, Boolean]) { testActor ! TestActor.SetIgnore(Some(f)) } def ignoreMsg(f: PartialFunction[Any, Boolean]) { testActor ! TestActor.SetIgnore(Some(f)) }
/** /**
* Stop ignoring messages in the test actor. * Stop ignoring messages in the test actor.

View file

@ -78,6 +78,13 @@ class TestProbeSpec extends AkkaSpec with DefaultTimeout {
expectMsgAllClassOf(5 seconds, classOf[Int]) must be(Seq(42)) expectMsgAllClassOf(5 seconds, classOf[Int]) must be(Seq(42))
} }
"be able to ignore primitive types" in {
ignoreMsg { case 42 true }
testActor ! 42
testActor ! "pigdog"
expectMsg("pigdog")
}
} }
} }