-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support for SCXML <cancel> tag. Allow cancelling delayed events
- Loading branch information
Showing
12 changed files
with
290 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- we test that specifying an illegal target for <send> causes the event error.execution to be raised. If it does, | ||
we succeed. Otherwise we eventually timeout and fail. --> | ||
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="ecmascript"> | ||
<state id="s0"> | ||
<onentry> | ||
<!-- should cause an error --> | ||
<send target="baz" event="event2"/> | ||
<!-- this will get added to the external event queue after the error has been raised --> | ||
<send event="timeout"/> | ||
</onentry> | ||
<!-- once we've entered the state, we should check for internal events first --> | ||
<transition event="error.execution" target="pass"/> | ||
<transition event="*" target="fail"/> | ||
</state> | ||
<final id="pass"> | ||
<onentry> | ||
<log label="Outcome" expr="'pass'"/> | ||
</onentry> | ||
</final> | ||
<final id="fail"> | ||
<onentry> | ||
<log label="Outcome" expr="'fail'"/> | ||
</onentry> | ||
</final> | ||
</scxml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- we test that if type is not provided <send> uses the scxml event i/o processor. The only way to | ||
tell | ||
what processor was used is to look at the origintype of the resulting event --> | ||
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" | ||
initial="s0" version="1.0" datamodel="ecmascript"> | ||
<state id="s0"> | ||
<onentry> | ||
<send event="event1" /> | ||
<send event="timeout" /> | ||
</onentry> | ||
<transition event="event1" | ||
cond=" _event.origintype == 'http://www.w3.org/TR/scxml/#SCXMLEventProcessor'" target="pass" /> | ||
<transition event="*" target="fail" /> | ||
</state> | ||
<final id="pass"> | ||
<onentry> | ||
<log label="Outcome" expr="'pass'" /> | ||
</onentry> | ||
</final> | ||
<final id="fail"> | ||
<onentry> | ||
<log label="Outcome" expr="'fail'" /> | ||
</onentry> | ||
</final> | ||
</scxml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- we test that using an invalid send type results in error.execution --> | ||
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" | ||
initial="s0" version="1.0" datamodel="ecmascript"> | ||
<state id="s0"> | ||
<onentry> | ||
<send type="27" event="event1" /> | ||
<send event="timeout" /> | ||
</onentry> | ||
<transition event="error.execution" target="pass" /> | ||
<transition event="*" target="fail" /> | ||
</state> | ||
<final id="pass"> | ||
<onentry> | ||
<log label="Outcome" expr="'pass'" /> | ||
</onentry> | ||
</final> | ||
<final id="fail"> | ||
<onentry> | ||
<log label="Outcome" expr="'fail'" /> | ||
</onentry> | ||
</final> | ||
</scxml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- we test that the processor supports the scxml event i/o processor --> | ||
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" | ||
initial="s0" datamodel="ecmascript" version="1.0"> | ||
<state id="s0"> | ||
<onentry> | ||
<send type="http://www.w3.org/TR/scxml/#SCXMLEventProcessor" event="event1" /> | ||
<send event="timeout" /> | ||
</onentry> | ||
<transition event="event1" target="pass" /> | ||
<transition event="*" target="fail" /> | ||
</state> | ||
<final id="pass"> | ||
<onentry> | ||
<log label="Outcome" expr="'pass'" /> | ||
</onentry> | ||
</final> | ||
<final id="fail"> | ||
<onentry> | ||
<log label="Outcome" expr="'fail'" /> | ||
</onentry> | ||
</final> | ||
</scxml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- we test that the processor doesn't change the message. We can't test that it never does this, | ||
but | ||
at least we can check that the event name and included data are the same as we sent. --> | ||
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" | ||
initial="s0" version="1.0" datamodel="ecmascript"> | ||
<datamodel> | ||
<data id="Var1" /> | ||
</datamodel> | ||
<state id="s0"> | ||
<onentry> | ||
<send event="event1"> | ||
<param name="aParam" expr="1" /> | ||
</send> | ||
<send event="timeout" /> | ||
</onentry> | ||
<transition event="event1" target="s1"> | ||
<assign location="Var1" expr="_event.data.aParam" /> | ||
</transition> | ||
<transition event="*" target="fail" /> | ||
</state> | ||
<state id="s1"> | ||
<transition cond="Var1==1" target="pass" /> | ||
<transition target="fail" /> | ||
</state> | ||
<final id="pass"> | ||
<onentry> | ||
<log label="Outcome" expr="'pass'" /> | ||
</onentry> | ||
</final> | ||
<final id="fail"> | ||
<onentry> | ||
<log label="Outcome" expr="'fail'" /> | ||
</onentry> | ||
</final> | ||
</scxml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scxml datamodel="ecmascript" initial="s0" name="ScxmlTest207" version="1.0" | ||
xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance"><!--We | ||
test that that we can't cancel an event in another session. | ||
We invoke a child process. It notifies us when it has generated | ||
a delayed event with sendid `foo`. We try to cancel `foo`. | ||
The child process sends us event. | ||
Event success if the event is not cancelled, event fail otherwise. | ||
This doesn't test that there is absolutely no way to cancel an event | ||
raised in another session, but the spec doesn't define any way | ||
to refer to an event in another process--> | ||
<state id="s0" initial="s01"> | ||
<onentry> | ||
<send delayexpr="'2s'" event="timeout" /> | ||
</onentry> | ||
<invoke type="scxml"> | ||
<content> | ||
<scxml datamodel="ecmascript" initial="sub0" name="ScxmlSub" version="1.0" | ||
xmlns="http://www.w3.org/2005/07/scxml"> | ||
<state id="sub0"> | ||
<onentry> | ||
<send delayexpr="'1s'" event="event1" id="foo" /> | ||
<send delayexpr="'1.5s'" event="event2" /> | ||
<send event="childToParent" target="#_parent" /> | ||
</onentry> | ||
<transition event="event1" target="subFinal"> | ||
<send target="#_parent" event="pass" /> | ||
</transition> | ||
<transition event="*" target="subFinal"> | ||
<send target="#_parent" event="fail" /> | ||
</transition> | ||
</state> | ||
<final id="subFinal" /> | ||
</scxml><!--when | ||
invoked, we raise a delayed event1 with sendid 'foo' and notify our parent. Then we | ||
wait. | ||
If event1 occurs, the parent hasn't succeeded in canceling it and we return pass. If event2 occurs | ||
it means event1 was canceled (because event2 is delayed longer than event1) and we return | ||
'fail'.--> | ||
</content> | ||
</invoke> | ||
<transition event="timeout" target="fail" /> | ||
<state id="s01"> | ||
<transition event="childToParent" target="s02"> | ||
<cancel sendid="foo" /> | ||
</transition> | ||
</state> | ||
<state id="s02"> | ||
<transition event="pass" target="pass" /> | ||
<transition event="fail" target="fail" /> | ||
</state> | ||
</state> | ||
<final id="pass"> | ||
<onentry> | ||
<log expr="'pass'" label="Outcome" /> | ||
</onentry> | ||
</final> | ||
<final id="fail"> | ||
<onentry> | ||
<log expr="'fail'" label="Outcome" /> | ||
</onentry> | ||
</final> | ||
</scxml> |
Oops, something went wrong.