test_19_swaptwice_combo.xml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. <param type="int"/>
  19. <param type="int"/>
  20. </event>
  21. <event name="swap_twice"/>
  22. </inport>
  23. <outport name="out">
  24. <event name="swapped">
  25. <param type="int"/>
  26. <param type="int"/>
  27. </event>
  28. </outport>
  29. <root initial="Swap">
  30. <parallel id="Swap">
  31. <transition event="set_a_b(a_: int, b_: int)" target=".">
  32. <code> a = a_; b = b_; </code>
  33. </transition>
  34. <state id="A" initial="S1">
  35. <state id="S1">
  36. <transition port="in" event="swap_twice" target="../S2">
  37. <code> a = b; </code>
  38. <raise event="swap_a"/>
  39. </transition>
  40. </state>
  41. <state id="S2">
  42. <transition event="swap_a" target="../S3">
  43. <code> a = b; </code>
  44. </transition>
  45. </state>
  46. <state id="S3"/>
  47. </state>
  48. <state id="B" initial="S4">
  49. <state id="S4">
  50. <transition port="in" event="swap_twice" target="../S5">
  51. <code> b = a; </code>
  52. <raise event="swap_a"/>
  53. </transition>
  54. </state>
  55. <state id="S5">
  56. <transition event="swap_a" target="../S6">
  57. <code> b = a; </code>
  58. </transition>
  59. </state>
  60. <state id="S6">
  61. <transition cond='@in("/Swap/A/S3")' target="/done">
  62. <raise event="swapped">
  63. <param expr="a"/>
  64. <param expr="b"/>
  65. </raise>
  66. </transition>
  67. </state>
  68. </state>
  69. </parallel>
  70. <state id="done"/>
  71. </root>
  72. </statechart>
  73. <input>
  74. <event port="in" name="set_a_b" time="0 d">
  75. <param expr="42"/>
  76. <param expr="7"/>
  77. </event>
  78. <event port="in" name="swap_twice" time="0 d"/>
  79. </input>
  80. <output>
  81. <big_step>
  82. <event port="out" name="swapped">
  83. <param val="42"/>
  84. <param val="7"/>
  85. </event>
  86. </big_step>
  87. </output>
  88. </test>