use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class SubstitutionTest method testInvalidIdentifierListInAnySubstitution.
@Test
public void testInvalidIdentifierListInAnySubstitution() throws BCompoundException {
final String testMachine = "#SUBSTITUTION ANY (x|->y) WHERE x = 1 & y = 1 THEN skip END ";
try {
getTreeAsString(testMachine);
fail("Expected exception");
} catch (final BCompoundException e) {
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class SubstitutionTest method testRenamedIdentifierInAnySubstitution.
@Test
public void testRenamedIdentifierInAnySubstitution() {
final String testMachine = "#SUBSTITUTION ANY x.y WHERE x.y = 1 THEN skip END ";
try {
getTreeAsString(testMachine);
fail("Expected exception");
} catch (final BCompoundException e) {
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class DefinitionsErrorsTest method checkForInvalidDefinition.
@Test
public void checkForInvalidDefinition() throws Exception {
String s = "MACHINE Definitions \n DEFINITIONS \n foo == BEING x :=1 END \nEND";
try {
getTreeAsString(s);
fail("Invalid substitution was not detected.");
} catch (BCompoundException e) {
System.out.println(e.getMessage());
// there is no token available, hence the position is in the text
assertTrue(e.getMessage().contains("[3,15]"));
assertTrue(e.getMessage().contains("expecting end of definition"));
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class DefinitionsErrorsTest 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 DefinitionsErrorsTest method checkForInvalidSubstitution.
@Test
public void checkForInvalidSubstitution() throws Exception {
String s = "MACHINE Definitions \n DEFINITIONS \n foo == BEGIN\n x=1 END \nEND";
try {
getTreeAsString(s);
fail("Invalid substitution was not detected.");
} catch (BCompoundException e) {
System.out.println(e.getMessage());
// there is no token available, hence the position is in the text
assertTrue(e.getMessage().contains("[4,3]"));
}
}
Aggregations