Ejemplo n.º 1
0
 @Test
 public void subwayTurnstileOne() throws Exception {
   SemanticStateMachine ast =
       produceAst(
           ""
               + "Actions: Turnstile\n"
               + "FSM: OneCoinTurnstile\n"
               + "Initial: Locked\n"
               + "{\n"
               + "  Locked\tCoin\tUnlocked\t{alarmOff unlock}\n"
               + "  Locked \tPass\tLocked\t\talarmOn\n"
               + "  Unlocked\tCoin\tUnlocked\tthankyou\n"
               + "  Unlocked\tPass\tLocked\t\tlock\n"
               + "}");
   assertThat(
       ast.toString(),
       equalTo(
           ""
               + "Actions: Turnstile\n"
               + "FSM: OneCoinTurnstile\n"
               + "Initial: Locked{\n"
               + "  Locked {\n"
               + "    Coin Unlocked {alarmOff unlock}\n"
               + "    Pass Locked {alarmOn}\n"
               + "  }\n"
               + "\n"
               + "  Unlocked {\n"
               + "    Coin Unlocked {thankyou}\n"
               + "    Pass Locked {lock}\n"
               + "  }\n"
               + "}\n"));
 }
Ejemplo n.º 2
0
 @Test
 public void subwayTurnstileThree() throws Exception {
   SemanticStateMachine ast =
       produceAst(
           ""
               + "Actions: Turnstile\n"
               + "FSM: TwoCoinTurnstile\n"
               + "Initial: Locked\n"
               + "{\n"
               + "    (Base)\tReset\tLocked\tlock\n"
               + "\n"
               + "\tLocked : Base {\n"
               + "\t\tPass\tAlarming\t-\n"
               + "\t\tCoin\tFirstCoin\t-\n"
               + "\t}\n"
               + "\t\n"
               + "\tAlarming : Base\t<alarmOn >alarmOff -\t-\t-\n"
               + "\t\n"
               + "\tFirstCoin : Base {\n"
               + "\t\tPass\tAlarming\t-\n"
               + "\t\tCoin\tUnlocked\tunlock\n"
               + "\t}\n"
               + "\t\n"
               + "\tUnlocked : Base {\n"
               + "\t\tPass\tLocked\tlock\n"
               + "\t\tCoin\t-\t\tthankyou\n"
               + "\t}\n"
               + "}");
   assertThat(
       ast.toString(),
       equalTo(
           ""
               + "Actions: Turnstile\n"
               + "FSM: TwoCoinTurnstile\n"
               + "Initial: Locked{\n"
               + "  Alarming :Base <alarmOn >alarmOff {\n"
               + "    null Alarming {}\n"
               + "  }\n"
               + "\n"
               + "  (Base) {\n"
               + "    Reset Locked {lock}\n"
               + "  }\n"
               + "\n"
               + "  FirstCoin :Base {\n"
               + "    Pass Alarming {}\n"
               + "    Coin Unlocked {unlock}\n"
               + "  }\n"
               + "\n"
               + "  Locked :Base {\n"
               + "    Pass Alarming {}\n"
               + "    Coin FirstCoin {}\n"
               + "  }\n"
               + "\n"
               + "  Unlocked :Base {\n"
               + "    Pass Locked {lock}\n"
               + "    Coin Unlocked {thankyou}\n"
               + "  }\n"
               + "}\n"));
 }
Ejemplo n.º 3
0
 private void assertSemanticResult(String s, String expected) {
   SemanticStateMachine semanticStateMachine = produceAst(s);
   assertEquals(expected, semanticStateMachine.toString());
 }