use of de.bmoth.parser.ast.nodes.FormulaNode 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.FormulaNode 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.FormulaNode in project bmoth by hhu-stups.
the class ASTTransformationTest method testElementOfCombinedWithIntersection.
@Test
public void testElementOfCombinedWithIntersection() {
String formula = "a : {1} /\\ b";
FormulaNode formulaNode = parseFormula(formula);
formulaNode = AstTransformationsForZ3.transformFormulaNode(formulaNode);
assertEquals("AND(ELEMENT_OF(a,SET_ENUMERATION(1)),ELEMENT_OF(a,b))", formulaNode.getFormula().toString());
}
use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.
the class ASTTransformationTest method testMemberOfIntervalToLeqGeq.
@Test
public void testMemberOfIntervalToLeqGeq() {
String formula = "a : 1..7";
FormulaNode formulaNode = parseFormula(formula);
formulaNode = AstTransformationsForZ3.transformFormulaNode(formulaNode);
assertEquals("AND(GREATER_EQUAL(a,1),LESS_EQUAL(a,7))", formulaNode.getFormula().toString());
}
use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.
the class ASTTransformationTest method testMemberOfIntervalInsideQuantifiersToLeqGeq.
@Test
public void testMemberOfIntervalInsideQuantifiersToLeqGeq() {
String formula = "!(a) . (a : 1..7)";
FormulaNode formulaNode = parseFormula(formula);
formulaNode = AstTransformationsForZ3.transformFormulaNode(formulaNode);
assertEquals("FORALL(a,AND(GREATER_EQUAL(a,1),LESS_EQUAL(a,7)))", formulaNode.getFormula().toString());
formula = "#(a) . (a : 1..7)";
formulaNode = parseFormula(formula);
formulaNode = AstTransformationsForZ3.transformFormulaNode(formulaNode);
assertEquals("EXISTS(a,AND(GREATER_EQUAL(a,1),LESS_EQUAL(a,7)))", formulaNode.getFormula().toString());
}
Aggregations