diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/uscxml/promela/test-complete.scxml | 154 | ||||
-rw-r--r-- | test/uscxml/promela/test-event-source-auto.scxml | 22 | ||||
-rwxr-xr-x | test/w3c/analyze_tests.pl | 21 | ||||
-rw-r--r-- | test/w3c/run_promela_test.cmake | 5 |
4 files changed, 193 insertions, 9 deletions
diff --git a/test/uscxml/promela/test-complete.scxml b/test/uscxml/promela/test-complete.scxml new file mode 100644 index 0000000..a96152b --- /dev/null +++ b/test/uscxml/promela/test-complete.scxml @@ -0,0 +1,154 @@ +<scxml datamodel="promela"> + + <datamodel> + <data id="foreachArray1" type="int[3]">[1,2,3]</data> + <data id="parallelVar1" type="int" expr="0"/> + <data id="ifVar1">{ foo: 1, bar: 'baz' }</data> + <data id="counter">{ itemSum: 0, indexSum: 0 }</data> + <data id="sendVar1" type="int" expr="4"/> + <data id="histVar1" type="int">0</data> + <data id="finalizeVar1" type="int">0</data> + </datamodel> + + <state id="s0"> + <history id="s0.h0" type="deep" /> + <parallel id="p0"> + <state id="p0.s0"> + <state id="p0.s0.s0"> + <onentry> + <if cond="ifVar1.foo == 3"> + <log label="if choosen" /> + <log label="ifVar1.bar is" expr="ifVar1.bar" /> + <foreach array="foreachArray1" + item="foreachItem1" + index="foreachIndex1"> + <script> + counter.indexSum = counter.indexSum + foreachIndex1; + counter.itemSum = counter.itemSum + foreachItem1; + </script> + <log label="foreach counter.indexSum is" + expr="counter.indexSum" /> + <log label="foreach counter.itemSum is" + expr="counter.itemSum" /> + </foreach> + <raise event="if.choosen" /> + <elseif cond="ifVar1.bar == 'baz'" /> + <log label="elseif choosen" /> + <log label="ifVar1.bar is" expr="ifVar1.bar" /> + <assign location="ifVar1.foo" expr="3" /> + <send event="elseif.choosen" namelist="sendVar1"> + <param name="foo" expr="sendVar1 + 16" /> + <param name="bar" expr="'a string literal'" /> + </send> + <else /> + <log label="else choosen" /> + <log label="ifVar1.foo is" expr="ifVar1.foo" /> + <log label="ifVar1.bar is" expr="ifVar1.bar" /> + <raise event="else.choosen" /> + </if> + <script>parallelVar1++</script> + </onentry> + <transition event="else.choosen" target="p0"> + <assign location="ifVar1.bar" expr="'baz'" /> + </transition> + <transition event="elseif.choosen" target="p0" + cond="_event.data.foo == 20 && + _event.data.sendVar1 == 4 && + _event.data.bar == 'a string literal'" + /> + </state> + <state id="p0.s0.s1"> + <onentry> + <if cond="_x.states['p0'] && histVar1 == 1"> + <raise event="to.s2" /> + <else /> + <raise event="to.s1" /> + </if> + </onentry> + <transition event="to.s2" target="s2" /> + <transition event="to.s1" target="s1" /> + </state> + </state> + <state id="p0.s1"> + <onexit> + <script>parallelVar1++</script> + </onexit> + </state> + <transition event="if.choosen" + cond="counter.itemSum == 6 && + counter.indexSum == 3" + target="p0.s0.s1" /> + </parallel> + </state> + + <state id="s1"> + <invoke type="scxml" autoforward="true"> + <content> + <scxml datamodel="promela"> + <state id="waitForEvent"> + <transition event="trigger.child"> + <send target="#_parent" event="back.to.history" /> + </transition> + </state> + </scxml> + </content> + <finalize> + <script>finalizeVar1++;</script> + </finalize> + </invoke> + <onentry> + <send event="trigger.child" delay="1000" /> + </onentry> + <transition event="back.to.history" + cond="finalizeVar1 == 1" + target="s0.h0"> + <assign location="histVar1" expr="4-3" /> + </transition> + </state> + + <state id="s2" initial="s2.s0"> + <onentry> + <send event="cancel.delayed" delay="3000" sendid="cancel.delayed" /> + <cancel sendid="cancel.delayed" /> + </onentry> + <transition event="done.state.s2" + cond="_event.data.Var1 == 'foo'" + target="s3.h0"> + <assign location="histVar1" expr="8" /> + </transition> + <transition event="done.state.s2" target="fail" /> + <transition event="cancel.delayed" target="fail" /> + <transition target="pass" cond="histVar1 == 8" /> + <state id="s2.s0"> + <transition target="s2.s1"/> + </state> + <final id="s2.s1"> + <donedata> + <param name="Var1" expr="'foo'"/> + </donedata> + </final> + </state> + + <state id="s3"> + <history id="s3.h0" type="shallow"> + <transition target="s3.s1"> + <log label="history transition" /> + <assign location="histVar1" expr="4" /> + </transition> + </history> + <state id="s3.s1"> + <transition target="s2" /> + </state> + </state> + + <final id="pass"> + <onentry> + <log label="Outcome" expr="'pass'"/> + </onentry> + </final> + <final id="fail"> + <onentry> + <log label="Outcome" expr="'fail'"/> + </onentry> + </final> +</scxml>
\ No newline at end of file diff --git a/test/uscxml/promela/test-event-source-auto.scxml b/test/uscxml/promela/test-event-source-auto.scxml new file mode 100644 index 0000000..ef0e26c --- /dev/null +++ b/test/uscxml/promela/test-event-source-auto.scxml @@ -0,0 +1,22 @@ +<scxml datamodel="promela"> + <!-- + #promela-event-source-auto + { e1: [ + { state: ['s0'], + data: { foo: 'some string' }} + { state: ['s0'], + data: { bar: 12 }} + { state: ['s1'], + data: { foo: 'some other string' }} + ]} + --> + + <state id="s0"> + <transition event="e1" cond="_event.data.foo == 'some string'" /> + <transition event="e1" cond="_event.data.bar == 12" /> + </state> + <state id="s1"> + <transition event="e1" cond="_event.data.foo == 'some other string'" /> + <transition event="e1" cond="_event.data.bar == 12" /> + </state> +</scxml>
\ No newline at end of file diff --git a/test/w3c/analyze_tests.pl b/test/w3c/analyze_tests.pl index 111db5a..a14c129 100755 --- a/test/w3c/analyze_tests.pl +++ b/test/w3c/analyze_tests.pl @@ -119,17 +119,22 @@ while ($block = <FILE>) { / Approximate\sComplexity:\s(\d+)\n Approximate\sActive\sComplexity:\s(\d+)\n - Actual\sComplexity:\s(\d+)\n - Actual\sActive\sComplexity:\s(\d+)\n - Internal\sQueue:\s(\d+)\n - External\sQueue:\s(\d+)\n /x ) { $test->{$currTest}->{'flat'}->{'cmplx'}->{'appr'} = $1; $test->{$currTest}->{'flat'}->{'cmplx'}->{'apprActv'} = $2; - $test->{$currTest}->{'flat'}->{'cmplx'}->{'actual'} = $3; - $test->{$currTest}->{'flat'}->{'cmplx'}->{'actualActv'} = $4; - $test->{$currTest}->{'flat'}->{'queue'}->{'internal'} = $5; - $test->{$currTest}->{'flat'}->{'queue'}->{'external'} = $6; + + if ($block =~ + / + Actual\sComplexity:\s(\d+)\n + Actual\sActive\sComplexity:\s(\d+)\n + Internal\sQueue:\s(\d+)\n + External\sQueue:\s(\d+)\n + /x ) { + $test->{$currTest}->{'flat'}->{'cmplx'}->{'actual'} = $1; + $test->{$currTest}->{'flat'}->{'cmplx'}->{'actualActv'} = $2; + $test->{$currTest}->{'flat'}->{'queue'}->{'internal'} = $3; + $test->{$currTest}->{'flat'}->{'queue'}->{'external'} = $4; + } if ($block =~ /State-vector (\d+) byte, depth reached (\d+), errors: (\d+)/) { $test->{$currTest}->{'pml'}->{'states'}->{'stateSize'} = $1; diff --git a/test/w3c/run_promela_test.cmake b/test/w3c/run_promela_test.cmake index e19148f..e6d2418 100644 --- a/test/w3c/run_promela_test.cmake +++ b/test/w3c/run_promela_test.cmake @@ -3,7 +3,10 @@ get_filename_component(TEST_FILE_NAME ${TESTFILE} NAME) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTDIR}) -execute_process(COMMAND ${USCXML_TRANSFORM_BIN} -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.pml RESULT_VARIABLE CMD_RESULT) +set(ENV{USCXML_PROMELA_TRANSITION_TRACE} "TRUE") +set(ENV{USCXML_PROMELA_TRANSITION_DEBUG} "TRUE") + +execute_process(COMMAND ${USCXML_TRANSFORM_BIN} -tpml -i ${TESTFILE} -o ${OUTDIR}/${TEST_FILE_NAME}.pml RESULT_VARIABLE CMD_RESULT) if(CMD_RESULT) message(FATAL_ERROR "Error running ${USCXML_TRANSFORM_BIN}: ${CMD_RESULT}") endif() |