summaryrefslogtreecommitdiffstats
path: root/test/w3c/lua/test207.scxml
blob: 7054edf89e9bcd4e15637ad09aa46acb470ef777 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?xml version="1.0" encoding="UTF-8"?>
<!-- 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  -->
<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" initial="s0" version="1.0" datamodel="lua">
  <state id="s0" initial="s01">
    <onentry>
      <send event="timeout" delayexpr="'2s'"/>
    </onentry>
    <invoke type="scxml">
      <content>
        <!-- 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'.  -->
        <scxml initial="sub0" version="1.0" datamodel="lua">
          <state id="sub0">
            <onentry>
              <send event="event1" id="foo" delayexpr="'1s'"/>
              <send event="event2" delayexpr="'1.5s'"/>
              <send target="#_parent" event="childToParent"/>
            </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>
      </content>
    </invoke>
    <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"/>
      <transition event="timeout" target="fail"/>
    </state>
  </state>
  <final xmlns:scxml="http://www.w3.org/2005/07/scxml" id="pass">
    <onentry>
      <log label="Outcome" expr="'pass'"/>
    </onentry>
  </final>
  <final xmlns:scxml="http://www.w3.org/2005/07/scxml" id="fail">
    <onentry>
      <log label="Outcome" expr="'fail'"/>
    </onentry>
  </final>
</scxml>