Choice.sctunit 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. testclass Choice for statechart Choice {
  2. @Test
  3. operation elseChoiceUsingNonDefaultTransition(){
  4. initForEventE(true)
  5. assert active (Choice.main_region.C)
  6. }
  7. @Test
  8. operation elseChoiceUsingDefaultTransition(){
  9. initForEventE(false)
  10. assert active (Choice.main_region.B)
  11. }
  12. @Test
  13. operation defaultChoiceUsingNonDefaultTransition(){
  14. initForEventG(true)
  15. assert active (Choice.main_region.C)
  16. }
  17. @Test
  18. operation defaultChoiceUsingDefaultTransition(){
  19. initForEventG(false)
  20. assert active (Choice.main_region.B)
  21. }
  22. @Test
  23. operation uncheckedChoiceUsingNonDefaultTransition(){
  24. initForEventF(true)
  25. assert active (Choice.main_region.C)
  26. }
  27. /*
  28. * An outgiong transition with an empty trigger
  29. * will be handled like a default transition.
  30. */
  31. @Test
  32. operation uncheckedChoiceUsingDefaultTransition(){
  33. initForEventF(false)
  34. assert active (Choice.main_region.B)
  35. }
  36. /* A transition with a 'true' guard is always true and must
  37. * be used according to its predefined priority.
  38. *
  39. * This test case makes sure that default transition reordering
  40. * does not impact these transitions.
  41. */
  42. @Test
  43. operation alwaysTrueTransitionInChoice(){
  44. initForEventH(true)
  45. assert active (Choice.main_region.C)
  46. }
  47. operation initForEventE(valueForC : boolean){
  48. enter
  49. assert active (Choice.main_region.A)
  50. c = valueForC
  51. raise e
  52. proceed 1 cycle
  53. }
  54. operation initForEventF(valueForC : boolean){
  55. enter
  56. assert active (Choice.main_region.A)
  57. c = valueForC
  58. raise f
  59. proceed 1 cycle
  60. }
  61. operation initForEventG(valueForC : boolean){
  62. enter
  63. assert active (Choice.main_region.A)
  64. c = valueForC
  65. raise g
  66. proceed 1 cycle
  67. }
  68. operation initForEventH(valueForC : boolean){
  69. enter
  70. assert active (Choice.main_region.A)
  71. c = valueForC
  72. raise h
  73. proceed 1 cycle
  74. }
  75. }