blob: 05cdd703ca6f76624fd7c2c529e845b3b78195ac (
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
56
57
58
59
60
61
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- test that an the legal iterable collections are arrays, namely objects that satisfy instanceof(Array) in ECMAScript.
the legal values for the 'item' attribute on foreach are legal ECMAScript variable names.. -->
<scxml:scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:conf="http://www.w3.org/2005/scxml-conformance" xmlns:scxml="http://www.w3.org/2005/07/scxml" initial="s0" datamodel="ecmascript" version="1.0">
<scxml:datamodel>
<scxml:data id="Var1" expr="0"/>
<scxml:data id="Var2"/>
<scxml:data id="Var3"/>
<scxml:data id="Var4" expr="7"/>
<scxml:data id="Var5" expr="[1,2,3]"/>
<scxml:data id="Var6"/>
</scxml:datamodel>
<scxml:state id="s0">
<scxml:onentry>
<!-- invalid array, legal item -->
<scxml:foreach item="Var2" index="Var3" array="Var4">
<scxml:assign location="Var1" expr="Var1 + 1"/>
</scxml:foreach>
<scxml:raise event="foo"/>
</scxml:onentry>
<scxml:transition event="error.execution" target="s1"/>
<scxml:transition event="*" target="fail"/>
</scxml:state>
<scxml:state id="s1">
<scxml:onentry>
<!-- illegal item, legal array -->
<scxml:foreach item="'continue'" index="Var3" array="Var5">
<scxml:assign location="Var1" expr="Var1 + 1"/>
</scxml:foreach>
<scxml:raise event="bar"/>
</scxml:onentry>
<scxml:transition event="error.execution" target="s2"/>
<scxml:transition event="bar" target="fail"/>
</scxml:state>
<scxml:state id="s2">
<!-- check that var1 has its original value (so executable content never got executed -->
<scxml:transition cond="Var1==0" target="s3"/>
<scxml:transition target="fail"/>
</scxml:state>
<!-- finally check that a legal array works properly -->
<scxml:state id="s3">
<scxml:onentry>
<scxml:assign location="Var6" expr="0"/>
<scxml:foreach item="Var2" array="Var5">
<scxml:assign location="Var6" expr="Var6 + Var2"/>
</scxml:foreach>
</scxml:onentry>
<scxml:transition cond="Var6==6" target="pass"/>
<scxml:transition target="fail"/>
</scxml:state>
<scxml:final id="pass">
<scxml:onentry>
<scxml:log label="Outcome" expr="'pass'"/>
</scxml:onentry>
</scxml:final>
<scxml:final id="fail">
<scxml:onentry>
<scxml:log label="Outcome" expr="'fail'"/>
</scxml:onentry>
</scxml:final>
</scxml:scxml>
|