use of pcgen.base.formula.base.EvaluationManager in project pcgen by PCGen.
the class AbstractFormulaTestCase method evaluatesTo.
public void evaluatesTo(String formula, SimpleNode node, Object valueOf) {
EvaluationManager manager = generateManager();
Object result = new EvaluateVisitor().visit(node, manager);
if (result.equals(valueOf)) {
return;
}
//Try ints as double as well just in case (temporary)
if (valueOf instanceof Integer) {
if (result.equals(valueOf)) {
return;
}
} else //Give Doubles a bit of fuzz
if (valueOf instanceof Double) {
if (TestUtilities.doubleEqual(((Double) valueOf).doubleValue(), ((Number) result).doubleValue(), TestUtilities.SMALL_ERROR)) {
return;
}
}
TestCase.fail("Expected " + valueOf.getClass().getSimpleName() + " (" + valueOf + ") for Formula: " + formula + ", was " + result + " (" + result.getClass().getSimpleName() + ")");
}
Aggregations