use of de.bmoth.parser.ast.nodes.DeclarationNode in project bmoth by hhu-stups.
the class OperatorCoverageTest method testExpressionFormula.
@Test
public void testExpressionFormula() {
String formula = "x - 2 / 3";
FormulaNode formulaNode = parseFormula(formula);
assertEquals(EXPRESSION_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 TestTypechecker method getFormulaTypes.
public static Map<String, String> getFormulaTypes(String formula) {
FormulaNode formulaNode;
try {
formulaNode = Parser.getFormulaAsSemanticAst(formula);
HashMap<String, String> map = new HashMap<>();
for (DeclarationNode decl : formulaNode.getImplicitDeclarations()) {
map.put(decl.getName(), decl.getType().toString());
}
return map;
} catch (ParserException e) {
fail(e.getMessage());
return null;
}
}
use of de.bmoth.parser.ast.nodes.DeclarationNode in project bmoth by hhu-stups.
the class NumbersTest method productTest.
@Test
public void productTest() 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());
}
use of de.bmoth.parser.ast.nodes.DeclarationNode in project bmoth by hhu-stups.
the class NumbersTest method greaterEqualTest.
@Test
public void greaterEqualTest() 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 minimumTest.
@Test
public void minimumTest() throws ParserException {
String formula = "x = min({1,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());
}
Aggregations