diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-05-12 19:44:16 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-05-12 19:44:16 (GMT) |
commit | 9a9afb6aaf314a68901cce3463e91512c261bd7a (patch) | |
tree | 20e7f888da47c67272cfd2c1c16d62e9189ed6c5 /test/uscxml/java | |
parent | 363250f8a9e33dc3f198f114fdfccd100b55ca12 (diff) | |
download | uscxml-9a9afb6aaf314a68901cce3463e91512c261bd7a.zip uscxml-9a9afb6aaf314a68901cce3463e91512c261bd7a.tar.gz uscxml-9a9afb6aaf314a68901cce3463e91512c261bd7a.tar.bz2 |
Started with JavaScript DM in Java (Rhino)
Diffstat (limited to 'test/uscxml/java')
-rw-r--r-- | test/uscxml/java/test-ecmascript-datamodel.scxml | 106 | ||||
-rw-r--r-- | test/uscxml/java/test-java-datamodel.scxml | 106 | ||||
-rw-r--r-- | test/uscxml/java/test-java-invoker.scxml | 40 |
3 files changed, 252 insertions, 0 deletions
diff --git a/test/uscxml/java/test-ecmascript-datamodel.scxml b/test/uscxml/java/test-ecmascript-datamodel.scxml new file mode 100644 index 0000000..4ec157c --- /dev/null +++ b/test/uscxml/java/test-ecmascript-datamodel.scxml @@ -0,0 +1,106 @@ +<scxml datamodel="java" initial="comparison" binding="late"> + <!-- unimplemented --> + <datamodel> + <data id="year" expr="2008" /> + <data id="CEO" expr="'Mr Big'" /> + <data id="profitable" /> + <data id="json"> + { + "id": 1, + "name": "Foo", + "price": 123, + "tags": [ "Bar", "Eek" ], + "stock": { + "warehouse": 300, + "retail": 20, + } + } + </data> + </datamodel> + <script> + var x = 4; + var a = ["a", "b", "c"]; + var b = [10,20,30]; + </script> + <script> + var y; + if (x > 10) { + y = 'true'; + } else { + y = 'false'; + } + </script> + <state id="comparison"> + <onentry> + <log expr="'-- Testing comparisons'" /> + <log expr="'x is ' + x + ', y is ' + y" /> + <if cond="x >= 2"> + <log expr="'x is greater or equal to 2'" /> + <else/> + <log expr="'x is smaller than 2'" /> + </if> + </onentry> + <transition target="builtin" /> + </state> + <state id="builtin"> + <onentry> + <log expr="'-- Testing built ins'" /> + <if cond="In('builtin')"> + <log expr="'We are in state builtin'" /> + <else/> + <log expr="'We are not in state builtin'" /> + </if> + </onentry> + <transition target="conditionals" /> + </state> + <state id="conditionals"> + <onentry> + <log expr="'-- Testing conditionals'" /> + <if cond="y == true"> + <log expr="'x is great and y is'" /> + <elseif cond="x > 3"> + <log expr="'x is somewhat great and y is not'" /> + </elseif> + <else> + <log expr="'x is great and y is not'" /> + </else> + </if> + </onentry> + <transition target="foreach" /> + </state> + <state id="foreach"> + <onentry> + <log expr="'-- Testing loops'" /> + <foreach array="a" item="itemA" index="indexA"> + <foreach array="b" item="itemB" index="indexB"> + <log expr="indexA + '.' + indexB + ' = ' + itemA + '.' + itemB" /> + </foreach> + </foreach> + </onentry> + <transition target="datamodels" /> + </state> + <state id="datamodels"> + <datamodel> + <data id="bar" expr="'yeah, bar!'"/> + </datamodel> + <onentry> + <log expr="'-- DataModels'" /> + <log expr="'year = ' + year" /> + <log expr="'bar = ' + bar" /> + <log expr="'json.stock.warehouse = ' + json.stock.warehouse" /> + </onentry> + <transition target="syntaxerror" /> + </state> + <state id="syntaxerror"> + <onentry> + <log expr="'-- Syntax Error'" /> + <log expr="year = ' + year" /> + </onentry> + <transition event="error.execution" target="final" /> + </state> + <final id="final"> + <onentry> + <log expr="'Finished!'" /> + </onentry> + </final> +</scxml>
\ No newline at end of file diff --git a/test/uscxml/java/test-java-datamodel.scxml b/test/uscxml/java/test-java-datamodel.scxml new file mode 100644 index 0000000..4ec157c --- /dev/null +++ b/test/uscxml/java/test-java-datamodel.scxml @@ -0,0 +1,106 @@ +<scxml datamodel="java" initial="comparison" binding="late"> + <!-- unimplemented --> + <datamodel> + <data id="year" expr="2008" /> + <data id="CEO" expr="'Mr Big'" /> + <data id="profitable" /> + <data id="json"> + { + "id": 1, + "name": "Foo", + "price": 123, + "tags": [ "Bar", "Eek" ], + "stock": { + "warehouse": 300, + "retail": 20, + } + } + </data> + </datamodel> + <script> + var x = 4; + var a = ["a", "b", "c"]; + var b = [10,20,30]; + </script> + <script> + var y; + if (x > 10) { + y = 'true'; + } else { + y = 'false'; + } + </script> + <state id="comparison"> + <onentry> + <log expr="'-- Testing comparisons'" /> + <log expr="'x is ' + x + ', y is ' + y" /> + <if cond="x >= 2"> + <log expr="'x is greater or equal to 2'" /> + <else/> + <log expr="'x is smaller than 2'" /> + </if> + </onentry> + <transition target="builtin" /> + </state> + <state id="builtin"> + <onentry> + <log expr="'-- Testing built ins'" /> + <if cond="In('builtin')"> + <log expr="'We are in state builtin'" /> + <else/> + <log expr="'We are not in state builtin'" /> + </if> + </onentry> + <transition target="conditionals" /> + </state> + <state id="conditionals"> + <onentry> + <log expr="'-- Testing conditionals'" /> + <if cond="y == true"> + <log expr="'x is great and y is'" /> + <elseif cond="x > 3"> + <log expr="'x is somewhat great and y is not'" /> + </elseif> + <else> + <log expr="'x is great and y is not'" /> + </else> + </if> + </onentry> + <transition target="foreach" /> + </state> + <state id="foreach"> + <onentry> + <log expr="'-- Testing loops'" /> + <foreach array="a" item="itemA" index="indexA"> + <foreach array="b" item="itemB" index="indexB"> + <log expr="indexA + '.' + indexB + ' = ' + itemA + '.' + itemB" /> + </foreach> + </foreach> + </onentry> + <transition target="datamodels" /> + </state> + <state id="datamodels"> + <datamodel> + <data id="bar" expr="'yeah, bar!'"/> + </datamodel> + <onentry> + <log expr="'-- DataModels'" /> + <log expr="'year = ' + year" /> + <log expr="'bar = ' + bar" /> + <log expr="'json.stock.warehouse = ' + json.stock.warehouse" /> + </onentry> + <transition target="syntaxerror" /> + </state> + <state id="syntaxerror"> + <onentry> + <log expr="'-- Syntax Error'" /> + <log expr="year = ' + year" /> + </onentry> + <transition event="error.execution" target="final" /> + </state> + <final id="final"> + <onentry> + <log expr="'Finished!'" /> + </onentry> + </final> +</scxml>
\ No newline at end of file diff --git a/test/uscxml/java/test-java-invoker.scxml b/test/uscxml/java/test-java-invoker.scxml new file mode 100644 index 0000000..a226913 --- /dev/null +++ b/test/uscxml/java/test-java-invoker.scxml @@ -0,0 +1,40 @@ +<scxml datamodel="ecmascript"> + <script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" /> + <state id="start"> + <state id="invokeNull"> + <invoke type="java"> + <finalize> + <script>dump(_event);</script> + </finalize> + <content> + </content> + </invoke> + <transition event="*" target="invokeJSON" /> + </state> + <state id="invokeJSON"> + <invoke type="java"> + <content> + { + "foo": "bar", + "baz": 12 + } + </content> + <finalize> + <script>dump(_event);</script> + </finalize> + </invoke> + <transition event="*" target="invokeDOM" /> + </state> + <state id="invokeDOM"> + <invoke type="java"> + <content> + <foo></foo> + </content> + <finalize> + <script>dump(_event);</script> + </finalize> + </invoke> + <transition event="*" target="invokeNull" /> + </state> + </state> +</scxml>
\ No newline at end of file |