diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2018-11-02 22:50:08 +0100 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2019-05-13 20:26:43 +0200 |
| commit | da9dd0c3cb3d9a6b72b6fb4efd257d0449711f17 (patch) | |
| tree | 067491eb5e9cfdb6ba2977517f370cf9a995cbdc /odcsim-core/src/test | |
| parent | ce71a2ec7abadd4d82d89dfc1f7fd3f79076e37a (diff) | |
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.
Diffstat (limited to 'odcsim-core/src/test')
| -rw-r--r-- | odcsim-core/src/test/kotlin/com/atlarge/odcsim/ActorSystemTest.kt | 19 |
1 files changed, 18 insertions, 1 deletions
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<Unit>(), "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<Unit> { Behavior.same() }, "test") + assertThrows<IllegalArgumentException> { 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<Unit> { Behavior.unhandled() }, "test") + assertThrows<IllegalArgumentException> { system.run() } + } } } |
