ShallowHistory.sctunit 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. testclass ShallowHistory for statechart ShallowHistory {
  2. @Test
  3. operation shallowHistoryTest(){
  4. enter
  5. // Change active states to State9;
  6. raise event1
  7. proceed 1 cycle
  8. raise event3
  9. proceed 1 cycle
  10. raise event5
  11. proceed 1 cycle
  12. raise event7
  13. proceed 1 cycle
  14. assert !active ( ShallowHistory.mainRegion.State1)
  15. assert active (ShallowHistory.mainRegion.State2._region0.State4._region0.State7._region0.State9)
  16. // Leave State7. State9 should be saved as history.
  17. raise event6
  18. proceed 1 cycle
  19. assert !active (ShallowHistory.mainRegion.State2._region0.State4._region0.State7._region0.State9)
  20. assert active ( ShallowHistory.mainRegion.State2._region0.State4._region0.State6)
  21. // Reenter State7. State9 should be activated because of saved history.
  22. raise event5
  23. proceed 1 cycle
  24. assert !active ( ShallowHistory.mainRegion.State2._region0.State4._region0.State7._region0.State8)
  25. assert active (ShallowHistory.mainRegion.State2._region0.State4._region0.State7._region0.State9)
  26. // Leave State2. State4 and State9 should be saved as history.
  27. raise event2
  28. proceed 1 cycle
  29. assert !active (ShallowHistory.mainRegion.State2._region0.State4._region0.State7._region0.State9)
  30. assert active (ShallowHistory.mainRegion.State1)
  31. // Reenter State2. State6 should be activated (History of State2).
  32. raise event1
  33. proceed 1 cycle
  34. assert active (ShallowHistory.mainRegion.State2._region0.State4._region0.State6)
  35. assert!active (ShallowHistory.mainRegion.State1)
  36. // Reenter State7. State9 should be activated (History of State7).
  37. raise event5
  38. proceed 1 cycle
  39. assert !active(ShallowHistory.mainRegion.State2._region0.State4._region0.State6)
  40. assert active (ShallowHistory.mainRegion.State2._region0.State4._region0.State7._region0.State9)
  41. }
  42. }