Search in sources :

Example 56 with FormulaNode

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

the class ASTTransformationTest method testElementOfCombinedWithUnion.

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

Example 57 with FormulaNode

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

the class ConstantFoldingTest method testIntegerAddition.

@Test
public void testIntegerAddition() {
    String formula = "a = 1+2+3";
    FormulaNode formulaNode = parseFormula(formula);
    formulaNode = AstTransformationsForZ3.transformFormulaNode(formulaNode);
    assertEquals("EQUAL(a,6)", formulaNode.getFormula().toString());
}
Also used : FormulaNode(de.bmoth.parser.ast.nodes.FormulaNode) Test(org.junit.Test)

Example 58 with FormulaNode

use of de.bmoth.parser.ast.nodes.FormulaNode 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());
}
Also used : FormulaNode(de.bmoth.parser.ast.nodes.FormulaNode) DeclarationNode(de.bmoth.parser.ast.nodes.DeclarationNode) Test(org.junit.Test)

Example 59 with FormulaNode

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

the class CSTAnalyserTest method testNoWarningInFormula.

@Test
public void testNoWarningInFormula() {
    String formula = "(TRUE or FALSE) & FALSE";
    FormulaNode formulaNode = parseFormula(formula);
    List<String> warnings = formulaNode.getWarnings();
    assertEquals(0, warnings.size());
}
Also used : FormulaNode(de.bmoth.parser.ast.nodes.FormulaNode) Test(org.junit.Test)

Example 60 with FormulaNode

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

the class CSTAnalyserTest method testWarningInFormula.

@Test
public void testWarningInFormula() {
    String formula = "TRUE or FALSE & FALSE";
    FormulaNode formulaNode = parseFormula(formula);
    List<String> warnings = formulaNode.getWarnings();
    assertEquals(1, warnings.size());
    assertEquals("Ambiguous combination of operators 'or' (line 1, pos 5) and '&' (line 1, pos 14)." + " Use parentheses to avoid this.", warnings.get(0));
}
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