use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class SubstitutionTest method testParallelAssignWithNonIdentifier.
@Test
public void testParallelAssignWithNonIdentifier() throws BCompoundException {
final String testMachine = "#SUBSTITUTION xx,yy,5 := 5, 3, zz";
try {
getTreeAsString(testMachine);
fail("Expected exception");
} catch (final BCompoundException e) {
// final CheckException cause = (CheckException) e.getCause();
// assertEquals(1, cause.getNodes().length);
// assertNotNull(cause.getNodes()[0]);
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class AtelierBCompatibilityTest method testSysExtension.
@Test
public void testSysExtension() throws IOException, BCompoundException {
String PATH = "src/test/resources/atelierb/sys_extension/";
String file = PATH + "main.sys";
File f = new File(file);
BParser bparser = new BParser();
Start ast = bparser.parseFile(f, false);
assertNotNull(ast);
RecursiveMachineLoader rml = new RecursiveMachineLoader(PATH, bparser.getContentProvider());
rml.loadAllMachines(f, ast, bparser.getDefinitions());
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class DefinitionsErrorsTest method checkForInvalidExpression.
@Test
public void checkForInvalidExpression() throws Exception {
String s = "MACHINE Definitions \n DEFINITIONS \n foo == 1 + \nEND";
try {
getTreeAsString(s);
fail("Invalid definition was not detected.");
} catch (BCompoundException e) {
System.out.println(e.getMessage());
assertTrue(e.getMessage().contains("[4,1]"));
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class DefinitionsTest method testParamsCount1.
@Test
public void testParamsCount1() {
final String testMachine = "MACHINE Test\nDEFINITIONS\ndefExpr(x)==g(x)\nOPERATIONS\nop=BEGIN defExpr(x); defExpr END\nEND";
try {
getTreeAsString(testMachine);
fail("Expected exception was not thrown");
} catch (final BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
assertEquals(1, cause.getNodes().length);
assertNotNull(cause.getNodes()[0]);
assertEquals("Number of parameters doesn't match declaration of definition", cause.getLocalizedMessage());
// IGNORE, is expected
}
}
use of de.be4.classicalb.core.parser.exceptions.BCompoundException in project probparsers by bendisposto.
the class DefinitionsTest method testExprOrSubst3.
@Test
public void testExprOrSubst3() {
final String testMachine = "MACHINE Test\nDEFINITIONS\ndefExpr==g(x)\nOPERATIONS\nop=PRE defExpr=42 THEN defExpr END\nEND";
try {
getTreeAsString(testMachine);
fail("Expected exception was not thrown");
} catch (final BCompoundException e) {
final CheckException cause = (CheckException) e.getCause();
assertEquals("Expecting substitution here but found definition with type 'Expression'", cause.getLocalizedMessage());
// IGNORE, is expected
}
}
Aggregations