[statemachine] use lambda syntax
This commit is contained in:
parent
8565f1bb85
commit
87c16512eb
|
@ -1,3 +1,4 @@
|
||||||
|
import std/sugar
|
||||||
import pkg/asynctest
|
import pkg/asynctest
|
||||||
import pkg/questionable
|
import pkg/questionable
|
||||||
import pkg/chronos
|
import pkg/chronos
|
||||||
|
@ -54,20 +55,10 @@ suite "async state machines":
|
||||||
|
|
||||||
test "state2 moves to state3 on event":
|
test "state2 moves to state3 on event":
|
||||||
machine.start(state2)
|
machine.start(state2)
|
||||||
|
machine.schedule(state => state.onMoveToNextStateEvent())
|
||||||
proc moveToNextStateEvent(state: State): ?State =
|
|
||||||
state.onMoveToNextStateEvent()
|
|
||||||
|
|
||||||
machine.schedule(moveToNextStateEvent)
|
|
||||||
|
|
||||||
check eventually runs == [0, 1, 1]
|
check eventually runs == [0, 1, 1]
|
||||||
|
|
||||||
test "state transition will cancel the running state":
|
test "state transition will cancel the running state":
|
||||||
machine.start(state2)
|
machine.start(state2)
|
||||||
|
machine.schedule(state => state.onMoveToNextStateEvent())
|
||||||
proc moveToNextStateEvent(state: State): ?State =
|
|
||||||
state.onMoveToNextStateEvent()
|
|
||||||
|
|
||||||
machine.schedule(moveToNextStateEvent)
|
|
||||||
|
|
||||||
check eventually cancellations == [0, 1, 0]
|
check eventually cancellations == [0, 1, 0]
|
||||||
|
|
Loading…
Reference in New Issue