Search in sources :

Example 41 with DeclarationNode

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

the class FunctionsTest method totalFunctionTest.

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

Example 42 with DeclarationNode

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

the class FunctionsTest method functionApplicationTest.

@Test
public void functionApplicationTest() throws ParserException {
    String formula = "x = {1|->2, 2|->3,3|->4}(1)";
    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 43 with DeclarationNode

use of de.bmoth.parser.ast.nodes.DeclarationNode 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 44 with DeclarationNode

use of de.bmoth.parser.ast.nodes.DeclarationNode 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 45 with DeclarationNode

use of de.bmoth.parser.ast.nodes.DeclarationNode 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)

Aggregations

DeclarationNode (de.bmoth.parser.ast.nodes.DeclarationNode)93 Test (org.junit.Test)92 FormulaNode (de.bmoth.parser.ast.nodes.FormulaNode)91 Ignore (org.junit.Ignore)27 MachineNode (de.bmoth.parser.ast.nodes.MachineNode)2 ParserException (de.bmoth.parser.ParserException)1 AnySubstitutionNode (de.bmoth.parser.ast.nodes.AnySubstitutionNode)1 OperationNode (de.bmoth.parser.ast.nodes.OperationNode)1 HashMap (java.util.HashMap)1