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());
}
}
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");
}
}
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");
}
}
Aggregations