use of de.be4.classicalb.core.parser.exceptions.CheckException in project probparsers by bendisposto.
the class DefinitionsTest method testExprOrSubstWParams4.
@Test
public void testExprOrSubstWParams4() {
final String testMachine = "MACHINE Test\nDEFINITIONS\ndefExpr(x)==g(x)\nOPERATIONS\nop=BEGIN defExpr(x); a:=defExpr(x) END\nEND";
try {
getTreeAsString(testMachine);
fail("Expected exception was not thrown");
} catch (final BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
assertEquals("Expecting expression here but found definition with type 'Substitution'", cause.getLocalizedMessage());
// IGNORE, is expected
}
}
use of de.be4.classicalb.core.parser.exceptions.CheckException 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.CheckException 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.CheckException 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"));
}
}
use of de.be4.classicalb.core.parser.exceptions.CheckException in project probparsers by bendisposto.
the class StructuralTest method checkForMissingSemicolon.
@Test
public void checkForMissingSemicolon() throws Exception {
String s = "MACHINE MissingSemicolon\nOPERATIONS\n Foo=BEGIN skip END\n BAR= BEGIN r := xx END\nEND";
try {
getTreeAsString(s);
fail("Missing Semicolon was not detected");
} catch (BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
Node node = cause.getNodes()[0];
assertEquals(4, node.getStartPos().getLine());
assertEquals(3, node.getStartPos().getPos());
assertTrue(e.getMessage().contains("Semicolon missing"));
}
}
Aggregations