Search in sources :

Example 6 with SemanticsVisitor

use of pcgen.base.formula.visitor.SemanticsVisitor in project pcgen by PCGen.

the class AbstractFormulaTestCase method isValid.

public void isValid(String formula, SimpleNode node, FormatManager<?> formatManager, Class<?> assertedFormat) {
    SemanticsVisitor semanticsVisitor = new SemanticsVisitor();
    FormulaSemantics semantics = managerFactory.generateFormulaSemantics(localSetup.getFormulaManager(), getGlobalScope(), assertedFormat);
    semanticsVisitor.visit(node, semantics);
    if (!semantics.isValid()) {
        TestCase.fail("Expected Valid Formula: " + formula + " but was told: " + semantics.getReport());
    }
}
Also used : FormulaSemantics(pcgen.base.formula.base.FormulaSemantics) SemanticsVisitor(pcgen.base.formula.visitor.SemanticsVisitor)

Example 7 with SemanticsVisitor

use of pcgen.base.formula.visitor.SemanticsVisitor in project pcgen by PCGen.

the class AbstractFormulaTestCase method isNotValid.

protected void isNotValid(String formula, SimpleNode node, FormatManager<?> formatManager, Class<?> assertedFormat) {
    SemanticsVisitor semanticsVisitor = new SemanticsVisitor();
    FormulaSemantics semantics = managerFactory.generateFormulaSemantics(localSetup.getFormulaManager(), getGlobalScope(), assertedFormat);
    semanticsVisitor.visit(node, semantics);
    if (semantics.isValid()) {
        TestCase.fail("Expected Invalid Formula: " + formula + " but was valid");
    }
}
Also used : FormulaSemantics(pcgen.base.formula.base.FormulaSemantics) SemanticsVisitor(pcgen.base.formula.visitor.SemanticsVisitor)

Example 8 with SemanticsVisitor

use of pcgen.base.formula.visitor.SemanticsVisitor in project pcgen by PCGen.

the class DropIntoContextFunctionTest method testInvalidWrongFormat3.

@Test
public void testInvalidWrongFormat3() {
    String formula = "dropIntoContext(\"EQUIPMENT\", \"EquipKey\",\"Stuff\")";
    SimpleNode node = TestUtilities.doParse(formula);
    SemanticsVisitor semanticsVisitor = new SemanticsVisitor();
    FormulaSemantics semantics = generateFormulaSemantics(getFormulaManager(), getGlobalScope(), null);
    Object result = semanticsVisitor.visit(node, semantics);
    if (semantics.isValid() && (result instanceof Number)) {
        TestCase.fail("Expected Invalid Formula: " + formula + " but was valid");
    }
}
Also used : FormulaSemantics(pcgen.base.formula.base.FormulaSemantics) SimpleNode(pcgen.base.formula.parse.SimpleNode) SemanticsVisitor(pcgen.base.formula.visitor.SemanticsVisitor) Test(org.junit.Test)

Aggregations

FormulaSemantics (pcgen.base.formula.base.FormulaSemantics)8 SemanticsVisitor (pcgen.base.formula.visitor.SemanticsVisitor)8 Test (org.junit.Test)4 SimpleNode (pcgen.base.formula.parse.SimpleNode)4 VariableID (pcgen.base.formula.base.VariableID)3 VariableLibrary (pcgen.base.formula.base.VariableLibrary)3 LegalScope (pcgen.base.formula.base.LegalScope)2 ScopeInstance (pcgen.base.formula.base.ScopeInstance)2 ReconstructionVisitor (pcgen.base.formula.visitor.ReconstructionVisitor)2 Equipment (pcgen.core.Equipment)2 ConsolidatedListCommitStrategy (pcgen.rules.context.ConsolidatedListCommitStrategy)2 LoadContext (pcgen.rules.context.LoadContext)2 RuntimeLoadContext (pcgen.rules.context.RuntimeLoadContext)2 RuntimeReferenceContext (pcgen.rules.context.RuntimeReferenceContext)2 WriteableVariableStore (pcgen.base.formula.base.WriteableVariableStore)1 ColumnFormatFactory (pcgen.cdom.format.table.ColumnFormatFactory)1 DataTable (pcgen.cdom.format.table.DataTable)1 TableFormatFactory (pcgen.cdom.format.table.TableFormatFactory)1