Search in sources :

Example 51 with FormulaNode

use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.

the class LogicOperationsTest method disjunctionTest.

@Test
public void disjunctionTest() throws ParserException {
    String formula = "x < 3 or x > 4";
    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());
}
Also used : FormulaNode(de.bmoth.parser.ast.nodes.FormulaNode) DeclarationNode(de.bmoth.parser.ast.nodes.DeclarationNode) Test(org.junit.Test)

Example 52 with FormulaNode

use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.

the class LogicOperationsTest method negationTest.

@Test
public void negationTest() throws ParserException {
    String formula = "x = bool(not(3>2))";
    FormulaNode formulaNode = Parser.getFormulaAsSemanticAst(formula);
    assertEquals(PREDICATE_FORMULA, formulaNode.getFormulaType());
    DeclarationNode declarationNode = formulaNode.getImplicitDeclarations().get(0);
    assertEquals("x", declarationNode.getName());
    assertEquals(BOOL, declarationNode.getType().toString());
}
Also used : FormulaNode(de.bmoth.parser.ast.nodes.FormulaNode) DeclarationNode(de.bmoth.parser.ast.nodes.DeclarationNode) Test(org.junit.Test)

Example 53 with FormulaNode

use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.

the class LogicOperationsTest method inEqualityTest.

@Test
public void inEqualityTest() throws ParserException {
    String formula = "x /= 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());
}
Also used : FormulaNode(de.bmoth.parser.ast.nodes.FormulaNode) DeclarationNode(de.bmoth.parser.ast.nodes.DeclarationNode) Test(org.junit.Test)

Example 54 with FormulaNode

use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.

the class ASTTransformationTest method testElementOfCombinedWithMultipleIntersections.

@Test
public void testElementOfCombinedWithMultipleIntersections() {
    String formula = "a : {1} /\\ b /\\ c";
    FormulaNode formulaNode = parseFormula(formula);
    formulaNode = AstTransformationsForZ3.transformFormulaNode(formulaNode);
    assertEquals("AND(AND(ELEMENT_OF(a,SET_ENUMERATION(1)),ELEMENT_OF(a,b)),ELEMENT_OF(a,c))", formulaNode.getFormula().toString());
}
Also used : FormulaNode(de.bmoth.parser.ast.nodes.FormulaNode) Test(org.junit.Test)

Example 55 with FormulaNode

use of de.bmoth.parser.ast.nodes.FormulaNode in project bmoth by hhu-stups.

the class ASTTransformationTest method testElementOfCombinedWithMultipleUnions.

@Test
public void testElementOfCombinedWithMultipleUnions() {
    String formula = "a : {1} \\/ b \\/ c";
    FormulaNode formulaNode = parseFormula(formula);
    formulaNode = AstTransformationsForZ3.transformFormulaNode(formulaNode);
    assertEquals("OR(OR(ELEMENT_OF(a,SET_ENUMERATION(1)),ELEMENT_OF(a,b)),ELEMENT_OF(a,c))", formulaNode.getFormula().toString());
}
Also used : FormulaNode(de.bmoth.parser.ast.nodes.FormulaNode) Test(org.junit.Test)

Aggregations

FormulaNode (de.bmoth.parser.ast.nodes.FormulaNode)106 Test (org.junit.Test)102 DeclarationNode (de.bmoth.parser.ast.nodes.DeclarationNode)91 Ignore (org.junit.Ignore)27 ParserException (de.bmoth.parser.ParserException)2 BMoThParser (de.bmoth.antlr.BMoThParser)1 FormulaContext (de.bmoth.antlr.BMoThParser.FormulaContext)1 SemanticAstCreator (de.bmoth.parser.ast.SemanticAstCreator)1 TypeErrorException (de.bmoth.parser.ast.TypeErrorException)1 ViewModel (de.saxsys.mvvmfx.ViewModel)1 HashMap (java.util.HashMap)1