test_guard_readonly.xml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?xml version="1.0" ?>
  2. <test>
  3. <!-- A guard condition evaluation is allowed to write to temporary (stack) variables -->
  4. <statechart>
  5. <semantics
  6. big_step_maximality="take_many"/>
  7. <datamodel>
  8. inc_x = func(x: int) {
  9. x += 1;
  10. return False;
  11. };
  12. </datamodel>
  13. <inport name="in">
  14. <event name="start">
  15. <param type="int"/>
  16. </event>
  17. </inport>
  18. <outport name="out">
  19. <event name="ok"/>
  20. </outport>
  21. <root initial="s1">
  22. <state id="s1">
  23. <!-- 1st guard to be evaluated -->
  24. <!-- increments 'x', but only locally in the function inc_x -->
  25. <transition event="start(x: int)" cond="inc_x(x)" target="."/>
  26. <!-- 2nd guard to be evaluated. x is still 42 -->
  27. <transition event="start(x: int)" cond="x == 42" target="../s2"/>
  28. </state>
  29. <state id="s2">
  30. <onentry>
  31. <raise port="out" event="ok"/>
  32. </onentry>
  33. </state>
  34. </root>
  35. </statechart>
  36. <input>
  37. <event name="start" port="in" time="0 d">
  38. <param name="x" expr="42"/>
  39. </event>
  40. </input>
  41. <output>
  42. <big_step>
  43. <event port="out" name="ok"/>
  44. </big_step>
  45. </output>
  46. </test>