use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class DefinitionsOrderTest method testLinearOrder.
@Test
public void testLinearOrder() throws IOException, BCompoundException {
machine = new File(PATH + "DefinitionsOccurInLinearOrder.mch");
final BParser parser = new BParser(machine.getName());
Start start = parser.parseFile(machine, false);
assertNotNull(start);
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class StructuralTest method testRepeatingClauses.
@Test
public void testRepeatingClauses() {
final String testMachine = "MACHINE TestMachineX\n" + "VARIABLES a,b,c\n" + "CONSTANTS X,Y,Z\n" + "VARIABLES x,y,z\n" + "END";
try {
getTreeAsString(testMachine);
fail("Expecting exception");
} catch (final BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
assertEquals(2, cause.getNodes().length);
// IGNORE: is expected
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class StructuralTest method testMissingProperties.
@Test
public void testMissingProperties() {
final String testMachine = "MACHINE TestMachineX\n" + "CONSTANTS X,Y,Z\n" + "END";
try {
getTreeAsString(testMachine);
fail("Expecting exception");
} catch (final BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
assertEquals(1, cause.getNodes().length);
assertEquals("Clause(s) missing: PROPERTIES", cause.getMessage());
// IGNORE: is expected
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class StructuralTest method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException {
// System.out.println("Parsing: \"" + testMachine + "\":");
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, false);
// startNode.apply(new ASTPrinter());
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
final String string = ast2String.toString();
// System.out.println();
return string;
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class StructuralTest method checkForInvalidSemicolonBeforeEnd2.
@Test
public void checkForInvalidSemicolonBeforeEnd2() throws Exception {
String s = "MACHINE MissingSemicolon\nOPERATIONS\n Foo=BEGIN skip;skip\n; END\nEND";
try {
getTreeAsString(s);
fail("Invalid Semicolon was not detected");
} catch (BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
Node node = cause.getNodes()[0];
assertEquals(4, node.getStartPos().getLine());
assertEquals(1, node.getStartPos().getPos());
assertTrue(e.getMessage().contains("Invalid semicolon after last substitution"));
}
}
Aggregations