ScenarioParser extends ExtendedParser { public final Scenario readScenario() throws ParserException { skipUtf8Bom(); while (available()) { int lastPosition = -1; while (available() && lastPosition != currentPosition) { lastPosition = currentPosition; skipWhitespaces(); skipComments(); } if (available()) { readStatement(); } } return scenario; } ScenarioParser(String toParse); final Scenario readScenario(); final void readStatement();  }
@Test public void testMultipleVariableAssignments() throws ParserException { ScenarioParser parser = new ScenarioParser("var x = 15;var y = 16;"); parser.readScenario(); assertEquals(15f, parser.variables.get("x"), 0.0001); assertEquals(16f, parser.variables.get("y"), 0.0001); parser = new ScenarioParser("var x = 15;var y = x + 3;"); parser.readScenario(); assertEquals(15f, parser.variables.get("x"), 0.0001); assertEquals(18f, parser.variables.get("y"), 0.0001); }
@Test public void testComments() throws ParserException { ScenarioParser parser = new ScenarioParser("# Comment\n" + "var x = 5; # Assigns 5 to x\n" + "\n\n" + "var y = 10;"); parser.readScenario(); assertEquals(5f, parser.variables.get("x"), 0.0001); assertEquals(10f, parser.variables.get("y"), 0.0001); parser = new ScenarioParser("# Comment"); parser.readScenario(); }
@Test(expected = ParserException.class) public void testCommandArgumentCount() throws ParserException { ScenarioParser parser = new ScenarioParser("delay(5, 10);"); parser.readScenario(); }