use of de.bmoth.parser.ast.nodes.DeclarationNode in project bmoth by hhu-stups.
the class MachinesTest method testAOperationParameter.
@Test
public void testAOperationParameter() {
String machine = MACHINE_NAME;
machine += VARIABLES_X_Y;
machine += INVARIANT_X_Y;
machine += INITIALISATION_X_1_Y_TRUE;
machine += "OPERATIONS foo(p) = SELECT p = 1 THEN x := p END \n";
machine += "END";
MachineNode machineAsSemanticAst = parseMachine(machine);
OperationNode operationNode = machineAsSemanticAst.getOperations().get(0);
DeclarationNode p = operationNode.getParams().get(0);
assertEquals("p", p.getName());
assertEquals(INTEGER, p.getType().toString());
}
use of de.bmoth.parser.ast.nodes.DeclarationNode in project bmoth by hhu-stups.
the class MachinesTest method testAnySubstitution.
@Test
public void testAnySubstitution() {
String machine = MACHINE_NAME;
machine += VARIABLES_X_Y;
machine += INVARIANT_X_Y;
machine += INITIALISATION_X_1_Y_TRUE;
machine += "OPERATIONS foo = ANY p WHERE 1=1 THEN x := p END \n";
machine += "END";
MachineNode machineAsSemanticAst = parseMachine(machine);
AnySubstitutionNode any = (AnySubstitutionNode) machineAsSemanticAst.getOperations().get(0).getSubstitution();
DeclarationNode p = any.getParameters().get(0);
assertEquals("p", p.getName());
assertEquals(INTEGER, p.getType().toString());
}
use of de.bmoth.parser.ast.nodes.DeclarationNode in project bmoth by hhu-stups.
the class OperatorCoverageTest method testPredicateFormula.
@Test
public void testPredicateFormula() {
String formula = "a * b = x & b = 1";
FormulaNode formulaNode = parseFormula(formula);
assertEquals(PREDICATE_FORMULA, formulaNode.getFormulaType());
DeclarationNode node1 = formulaNode.getImplicitDeclarations().get(0);
DeclarationNode node2 = formulaNode.getImplicitDeclarations().get(1);
assertEquals("a", node1.getName());
assertEquals("b", node2.getName());
assertEquals(INTEGER, node1.getType().toString());
assertEquals(INTEGER, node2.getType().toString());
}
use of de.bmoth.parser.ast.nodes.DeclarationNode in project bmoth by hhu-stups.
the class NumbersTest method lessTest.
@Test
public void lessTest() throws ParserException {
String formula = "x > 2";
FormulaNode formulaNode = Parser.getFormulaAsSemanticAst(formula);
assertEquals(PREDICATE_FORMULA, formulaNode.getFormulaType());
DeclarationNode declarationNode = formulaNode.getImplicitDeclarations().get(0);
assertEquals("x", declarationNode.getName());
assertEquals(INTEGER, declarationNode.getType().toString());
}
use of de.bmoth.parser.ast.nodes.DeclarationNode in project bmoth by hhu-stups.
the class NumbersTest method differenceTest.
@Test
public void differenceTest() throws ParserException {
String formula = "x = 2 - 3";
FormulaNode formulaNode = Parser.getFormulaAsSemanticAst(formula);
assertEquals(PREDICATE_FORMULA, formulaNode.getFormulaType());
DeclarationNode declarationNode = formulaNode.getImplicitDeclarations().get(0);
assertEquals("x", declarationNode.getName());
assertEquals(INTEGER, declarationNode.getType().toString());
}
Aggregations