summaryrefslogtreecommitdiffstats
path: root/test/uscxml
diff options
context:
space:
mode:
authorStefan Radomski <sradomski@mintwerk.de>2015-12-04 08:00:18 (GMT)
committerStefan Radomski <sradomski@mintwerk.de>2015-12-04 08:00:18 (GMT)
commitb8ba0e7c31f397a66f9d509ff20a85b33619475a (patch)
tree9a5adb4f891cdc29eb80f597510e0cef8ee0a47f /test/uscxml
parent57ba362eae6e8209cf560555fd4cc4bb76dbe2a1 (diff)
downloaduscxml-b8ba0e7c31f397a66f9d509ff20a85b33619475a.zip
uscxml-b8ba0e7c31f397a66f9d509ff20a85b33619475a.tar.gz
uscxml-b8ba0e7c31f397a66f9d509ff20a85b33619475a.tar.bz2
All changes up to my dissertation
Diffstat (limited to 'test/uscxml')
-rw-r--r--test/uscxml/history-stacks/history-compounds.scxml53
-rw-r--r--test/uscxml/history-stacks/history-invokers.item.scxml30
-rw-r--r--test/uscxml/history-stacks/history-invokers.main.scxml24
-rw-r--r--test/uscxml/test-invoke-communication-invoker.scxml118
-rw-r--r--test/uscxml/test-invoke-communication.scxml104
-rw-r--r--test/uscxml/transition-selection/test1.scxml12
-rw-r--r--test/uscxml/transition-selection/test2.scxml20
7 files changed, 361 insertions, 0 deletions
diff --git a/test/uscxml/history-stacks/history-compounds.scxml b/test/uscxml/history-stacks/history-compounds.scxml
new file mode 100644
index 0000000..0fbca92
--- /dev/null
+++ b/test/uscxml/history-stacks/history-compounds.scxml
@@ -0,0 +1,53 @@
+<scxml datamodel="ecmascript">
+ <datamodel>
+ <data id="stack">[]</data>
+ </datamodel>
+
+ <initial>
+ <transition target="main">
+ <send event="to.item1" />
+ <send event="to.item2" />
+ <send event="to.item1" />
+ <send event="back" />
+ <send event="back" />
+ <send event="back" />
+ </transition>
+ </initial>
+
+ <parallel id="main">
+ <state id="controller">
+ <transition event="to.item1"
+ target="item1.history">
+ <script>stack.push("item1");</script>
+ </transition>
+ <transition event="to.item2"
+ target="item2.history">
+ <script>stack.push("item2");</script>
+ </transition>
+
+ <transition event="back"
+ cond="stack[stack.length-1] === 'item1'"
+ target="item1">
+ <script>stack.pop();</script>
+ </transition>
+ <transition event="back"
+ cond="stack[stack.length-1] === 'item2'"
+ target="item2">
+ <script>stack.pop();</script>
+ </transition>
+ </state>
+
+ <state id="items">
+ <state id="item1">
+ <history type="deep"
+ id="item1.history" />
+ <!-- interaction would be established here -->
+ </state>
+ <state id="item2">
+ <history type="deep"
+ id="item2.history" />
+ <!-- interaction would be established here -->
+ </state>
+ </state>
+ </parallel>
+</scxml> \ No newline at end of file
diff --git a/test/uscxml/history-stacks/history-invokers.item.scxml b/test/uscxml/history-stacks/history-invokers.item.scxml
new file mode 100644
index 0000000..30f1a02
--- /dev/null
+++ b/test/uscxml/history-stacks/history-invokers.item.scxml
@@ -0,0 +1,30 @@
+<scxml datamodel="ecmascript">
+ <datamodel>
+ <data id="item" />
+ <data id="childItem" />
+ </datamodel>
+
+ <state>
+
+ <state id="show">
+ <!-- interaction would be established here -->
+ <transition event="to.item1" target="down">
+ <assign location="childItem" expr="1" />
+ </transition>
+ <transition event="to.item2" target="down">
+ <assign location="childItem" expr="2" />
+ </transition>
+ <transition event="back" target="done" />
+ </state>
+
+ <state id="down">
+ <invoke src="history-invokers.item.scxml"
+ autoforward="true">
+ <param name="item" expr="childItem" />
+ </invoke>
+ </state>
+ <transition event="done.invoke" target="show" />
+ </state>
+
+ <final id="done" />
+</scxml> \ No newline at end of file
diff --git a/test/uscxml/history-stacks/history-invokers.main.scxml b/test/uscxml/history-stacks/history-invokers.main.scxml
new file mode 100644
index 0000000..eec3e79
--- /dev/null
+++ b/test/uscxml/history-stacks/history-invokers.main.scxml
@@ -0,0 +1,24 @@
+<scxml datamodel="ecmascript">
+ <initial>
+ <transition target="main">
+ <send event="to.item1" />
+ <send event="to.item2" />
+ <send event="to.item1" />
+ <send event="back" delay="200ms"/>
+ <send event="back" delay="300ms"/>
+ <send event="back" delay="400ms"/>
+ <!-- terminate 'main' as well -->
+ <send event="back" delay="500ms"/>
+ </transition>
+ </initial>
+
+ <state id="main">
+ <invoke src="history-invokers.item.scxml"
+ autoforward="true">
+ <param name="item" expr="'main'" />
+ </invoke>
+ <transition event="done.invoke"
+ target="done" />
+ </state>
+ <final id="done" />
+</scxml> \ No newline at end of file
diff --git a/test/uscxml/test-invoke-communication-invoker.scxml b/test/uscxml/test-invoke-communication-invoker.scxml
new file mode 100644
index 0000000..98d089d
--- /dev/null
+++ b/test/uscxml/test-invoke-communication-invoker.scxml
@@ -0,0 +1,118 @@
+<scxml>
+ <!-- invoke and communicate on entry - will fail -->
+ <state id="send.onentry">
+ <invoke type="scxml" id="send.onentry.invoker">
+ <content>
+ <scxml>
+ <state>
+ <transition event="finish" target="done" />
+ </state>
+ <final id="done"/>
+ </scxml>
+ </content>
+ </invoke>
+
+ <onentry>
+ <!-- This will fail as invoker is not yet instantiated -->
+ <send target="#_send.onentry.invoker" event="finish"/>
+ </onentry>
+
+ <transition event="done.invoke.send.onentry.invoker" target="send.onentry.pass" />
+ <transition event="error.communication" target="send.onentry.fail" />
+ </state>
+
+ <state id="send.onentry.pass">
+ <transition target="external.event" />
+ </state>
+ <state id="send.onentry.fail">
+ <transition target="external.event" />
+ </state>
+
+
+ <!-- Invoke and send an event to the external queue which will trigger communication -->
+ <state id="external.event">
+ <invoke type="scxml" id="external.event.invoker">
+ <content>
+ <scxml>
+ <state>
+ <transition event="finish" target="done" />
+ </state>
+ <final id="done"/>
+ </scxml>
+ </content>
+ </invoke>
+
+ <onentry>
+ <send event="send.to.invoker"/>
+ </onentry>
+ <transition type="internal" event="send.to.invoker">
+ <!-- This will succeed as invoker was instantiated -->
+ <send target="#_external.event.invoker" event="finish"/>
+ </transition>
+
+ <transition event="done.invoke.external.event.invoker" target="external.event.pass" />
+ <transition event="error.communication" target="external.event.fail" />
+
+ </state>
+
+ <state id="external.event.pass">
+ <transition target="delayed.event" />
+ </state>
+ <state id="external.event.fail">
+ <transition target="delayed.event" />
+ </state>
+
+ <!-- invoke and communicate delayed on entry - will succeed -->
+ <state id="delayed.event">
+ <invoke type="scxml" id="delayed.event.invoker">
+ <content>
+ <scxml>
+ <state>
+ <transition event="finish" target="done" />
+ </state>
+ <final id="done"/>
+ </scxml>
+ </content>
+ </invoke>
+
+ <onentry>
+ <!-- This will succeed as the invoker will be instantiated in 1ms (invoking is synchronous) -->
+ <send target="#_delayed.event.invoker" event="finish" delay="1ms"/>
+ </onentry>
+
+ <transition event="done.invoke.delayed.event.invoker" target="delayed.event.pass" />
+ <transition event="error.communication" target="delayed.event.fail" />
+ </state>
+
+ <state id="delayed.event.pass">
+ <transition target="callback.event" />
+ </state>
+ <state id="delayed.event.fail">
+ <transition target="callback.event" />
+ </state>
+
+ <!-- invoke with callback event (out of spec, but so useful!) -->
+ <state id="callback.event">
+ <invoke type="scxml" id="callback.event.invoker" callback="init">
+ <content>
+ <scxml>
+ <state>
+ <transition event="finish" target="done" />
+ </state>
+ <final id="done"/>
+ </scxml>
+ </content>
+ </invoke>
+
+ <transition event="init.callback.event.invoker">
+ <send target="#_callback.event.invoker" event="finish" />
+ </transition>
+
+ <transition event="done.invoke.callback.event.invoker" target="callback.event.pass" />
+ <transition event="error.communication" target="callback.event.fail" />
+ </state>
+
+ <final id="callback.event.pass" />
+ <final id="callback.event.fail" />
+
+</scxml> \ No newline at end of file
diff --git a/test/uscxml/test-invoke-communication.scxml b/test/uscxml/test-invoke-communication.scxml
new file mode 100644
index 0000000..8d277ef
--- /dev/null
+++ b/test/uscxml/test-invoke-communication.scxml
@@ -0,0 +1,104 @@
+<scxml>
+ <!-- invoke and communicate on entry - will fail -->
+ <state id="send.onentry">
+ <invoke type="scxml"
+ id="send.onentry.invoker"
+ src="test-invoke-communication-invoker.scxml" />
+
+ <onentry>
+ <!-- This will fail as invoker is not yet instantiated -->
+ <send target="#_send.onentry.invoker"
+ event="finish"/>
+ </onentry>
+
+ <transition event="done.invoke.send.onentry.invoker"
+ target="send.onentry.pass" />
+ <transition event="error.communication"
+ target="send.onentry.fail" />
+ </state>
+
+ <state id="send.onentry.pass">
+ <transition target="external.event" />
+ </state>
+ <state id="send.onentry.fail">
+ <transition target="external.event" />
+ </state>
+
+
+ <!-- Invoke and send an event to the external queue which will trigger communication -->
+ <state id="external.event">
+ <invoke type="scxml"
+ id="external.event.invoker"
+ src="test-invoke-communication-invoker.scxml" />
+
+ <onentry>
+ <send event="send.to.invoker"/>
+ </onentry>
+ <transition type="internal"
+ event="send.to.invoker">
+ <!-- This will succeed as invoker was instantiated -->
+ <send target="#_external.event.invoker"
+ event="finish"/>
+ </transition>
+
+ <transition event="done.invoke.external.event.invoker"
+ target="external.event.pass" />
+ <transition event="error.communication"
+ target="external.event.fail" />
+ </state>
+
+ <state id="external.event.pass">
+ <transition target="delayed.event" />
+ </state>
+ <state id="external.event.fail">
+ <transition target="delayed.event" />
+ </state>
+
+ <!-- invoke and communicate delayed on entry - will succeed -->
+ <state id="delayed.event">
+ <invoke type="scxml"
+ id="delayed.event.invoker"
+ src="test-invoke-communication-invoker.scxml" />
+
+ <onentry>
+ <!-- This will succeed as the invoker will be instantiated in 1ms (invoking is synchronous) -->
+ <send target="#_delayed.event.invoker"
+ event="finish"
+ delay="1ms"/>
+ </onentry>
+
+ <transition event="done.invoke.delayed.event.invoker"
+ target="delayed.event.pass" />
+ <transition event="error.communication"
+ target="delayed.event.fail" />
+ </state>
+
+ <state id="delayed.event.pass">
+ <transition target="callback.event" />
+ </state>
+ <state id="delayed.event.fail">
+ <transition target="callback.event" />
+ </state>
+
+ <!-- invoke with callback event (out of spec, but so useful!) -->
+ <state id="callback.event">
+ <invoke type="scxml"
+ id="callback.event.invoker"
+ callback="init"
+ src="test-invoke-communication-invoker.scxml" />
+
+ <transition event="init.callback.event.invoker">
+ <send target="#_callback.event.invoker"
+ event="finish" />
+ </transition>
+
+ <transition event="done.invoke.callback.event.invoker"
+ target="callback.event.pass" />
+ <transition event="error.communication"
+ target="callback.event.fail" />
+ </state>
+
+ <final id="callback.event.pass" />
+ <final id="callback.event.fail" />
+
+</scxml> \ No newline at end of file
diff --git a/test/uscxml/transition-selection/test1.scxml b/test/uscxml/transition-selection/test1.scxml
new file mode 100644
index 0000000..d6f43cd
--- /dev/null
+++ b/test/uscxml/transition-selection/test1.scxml
@@ -0,0 +1,12 @@
+<scxml>
+ <parallel id="p1">
+ <state id="s1">
+ <transition target="pass" />
+ </state>
+ <state id="s2">
+ <transition target="fail" />
+ </state>
+ </parallel>
+ <final id="pass" />
+ <final id="fail" />
+</scxml> \ No newline at end of file
diff --git a/test/uscxml/transition-selection/test2.scxml b/test/uscxml/transition-selection/test2.scxml
new file mode 100644
index 0000000..4b703f8
--- /dev/null
+++ b/test/uscxml/transition-selection/test2.scxml
@@ -0,0 +1,20 @@
+<scxml>
+ <parallel id="p1">
+ <transition target="fail" />
+ <state id="s1" />
+ <state id="s2">
+ <state id="s2.s1">
+ <transition target="pass" />
+ </state>
+ </state>
+ <state id="s3">
+ <state id="s3.s1">
+ <state id="s3.s1.s1">
+ <transition target="fail" />
+ </state>
+ </state>
+ </state>
+ </parallel>
+ <final id="pass" />
+ <final id="fail" />
+</scxml> \ No newline at end of file