test_19_swaptwice_combo.xml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <test>
  2. <!-- Example 19. Statechart from Figure 21, extended with an input event to set the variables a,b, and with an output event to retreive the values (because currently, testing is black-box) -->
  3. <statechart>
  4. <semantics
  5. big_step_maximality="take_many"
  6. combo_step_maximality="take_one"
  7. input_event_lifeline="first_combo_step"
  8. internal_event_lifeline="next_combo_step"
  9. enabledness_memory_protocol="combo_step"
  10. assignment_memory_protocol="combo_step"
  11. />
  12. <datamodel>
  13. a = 0;
  14. b = 0;
  15. </datamodel>
  16. <inport name="in">
  17. <event name="set_a_b"/>
  18. <event name="swap_twice"/>
  19. </inport>
  20. <outport name="out">
  21. <event name="swapped"/>
  22. </outport>
  23. <root initial="Swap">
  24. <parallel id="Swap">
  25. <transition event="set_a_b(a_: int, b_: int)" target=".">
  26. <code> a = a_; b = b_; </code>
  27. </transition>
  28. <state id="A" initial="S1">
  29. <state id="S1">
  30. <transition port="in" event="swap_twice" target="../S2">
  31. <code> a = b; </code>
  32. <raise event="swap_a"/>
  33. </transition>
  34. </state>
  35. <state id="S2">
  36. <transition event="swap_a" target="../S3">
  37. <code> a = b; </code>
  38. </transition>
  39. </state>
  40. <state id="S3"/>
  41. </state>
  42. <state id="B" initial="S4">
  43. <state id="S4">
  44. <transition port="in" event="swap_twice" target="../S5">
  45. <code> b = a; </code>
  46. <raise event="swap_a"/>
  47. </transition>
  48. </state>
  49. <state id="S5">
  50. <transition event="swap_a" target="../S6">
  51. <code> b = a; </code>
  52. </transition>
  53. </state>
  54. <state id="S6">
  55. <transition cond='@in("/Swap/A/S3")' target="/done">
  56. <raise event="swapped">
  57. <param expr="a"/>
  58. <param expr="b"/>
  59. </raise>
  60. </transition>
  61. </state>
  62. </state>
  63. </parallel>
  64. <state id="done"/>
  65. </root>
  66. </statechart>
  67. <input>
  68. <event port="in" name="set_a_b" time="0 d">
  69. <param expr="42"/>
  70. <param expr="7"/>
  71. </event>
  72. <event port="in" name="swap_twice" time="0 d"/>
  73. </input>
  74. <output>
  75. <big_step>
  76. <event port="out" name="swapped">
  77. <param val="42"/>
  78. <param val="7"/>
  79. </event>
  80. </big_step>
  81. </output>
  82. </test>