From da9dd0c3cb3d9a6b72b6fb4efd257d0449711f17 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 2 Nov 2018 22:50:08 +0100 Subject: feat: Add support for suspending behavior This change adds support for suspending behavior via Kotlin's coroutine feature officially introduced in Kotlin 1.3. The syntax is similar to the 1.x version of the simulator to allow for easier porting to 2.x. --- .../test/kotlin/com/atlarge/odcsim/ActorSystemTest.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'odcsim-core/src/test') diff --git a/odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemTest.kt b/odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemTest.kt index 73b060b9..492dc686 100644 --- a/odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemTest.kt +++ b/odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemTest.kt @@ -250,7 +250,6 @@ abstract class ActorSystemTest { Behavior.ignore() }, "child") - Behavior.receive { ctx2, msg -> assertTrue(ctx2.stop(child)) msg.send(Unit) // This actor should be stopped now and not receive the message anymore @@ -332,5 +331,23 @@ abstract class ActorSystemTest { val system = factory(Behavior.stopped(), "test") system.run() } + + /** + * Test whether deferred behavior that returns [Behavior.Companion.same] fails. + */ + @Test + fun `should not allow setup to return same`() { + val system = factory(Behavior.setup { Behavior.same() }, "test") + assertThrows { system.run() } + } + + /** + * Test whether deferred behavior that returns [Behavior.Companion.unhandled] fails. + */ + @Test + fun `should not allow setup to return unhandled`() { + val system = factory(Behavior.setup { Behavior.unhandled() }, "test") + assertThrows { system.run() } + } } } -- cgit v1.2.3