Search in sources :

Example 66 with FormulaNode

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

the class NumbersTest method quotientTest.

@Test
public void quotientTest() throws ParserException {
    String formula = "x = 6 / 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 67 with FormulaNode

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

the class RelationTest method rightOverridingTest.

@Test
public void rightOverridingTest() throws ParserException {
    String formula = "x = {1|->2}<+{1|->3}";
    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) Test(org.junit.Test)

Example 68 with FormulaNode

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

the class RelationTest method directProductTest.

@Test
public void directProductTest() throws ParserException {
    String formula = "x = {1|->2}><{1|->3}";
    FormulaNode formulaNode = Parser.getFormulaAsSemanticAst(formula);
    assertEquals(PREDICATE_FORMULA, formulaNode.getFormulaType());
    DeclarationNode declarationNode = formulaNode.getImplicitDeclarations().get(0);
    assertEquals("x", declarationNode.getName());
    assertEquals("POW(INTEGER*(INTEGER*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 69 with FormulaNode

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

the class RelationTest method identityTest.

@Test
@Ignore
public void identityTest() throws ParserException {
    String formula = "x = id({1,2})";
    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 70 with FormulaNode

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

the class RelationTest method projection1Test.

@Test
@Ignore
public void projection1Test() throws ParserException {
    String formula = "x = prj1({1,2},{3,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)

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