assertEquals(type, token.getType() == null ? "" : token.getType().toString());
assertEquals(subtype, token.getSubtype() == null ? "" : token.getSubtype().toString());
}
public void testEvaluate1() {
Token root = null;
String expr = "=1+2+3";
Object x = parser.parse(expr, null, null).evaluate(null);
assertEquals(6.0, ((Number)x).doubleValue(), 0);
expr = "=1+\"2\"+3";
x = parser.parse(expr, null, null).evaluate(null);
assertEquals(6.0, ((Number)x).doubleValue(), 0);
expr = "=\"1\"+\"2\"+3";
x = parser.parse(expr, null, null).evaluate(null);
assertEquals(6.0, ((Number)x).doubleValue(), 0);
expr = "=1 + \"2\" * 3 + 4%";
x = parser.parse(expr, null, null).evaluate(null);
assertEquals(7.04, ((Number)x).doubleValue(), 0);
expr = "=\"1\" & \"2\" * 3 + 4%";
x = parser.parse(expr, null, null).evaluate(null);
assertEquals("16.04", x);
expr = "=\"1\" & \"2\"^3 + 4%";
x = parser.parse(expr, null, null).evaluate(null);
assertEquals("18.04", x);
expr = "=\"1\" & \"2\"^3 + 4% / 0";
root = parser.parse(expr, null, null);
try {
x = root.evaluate(null);
} catch (SSErrorXelException ex) {
assertEquals(SSError.DIV0, ex.getSSError());
}
expr = "=1234567890^1E+96";
root = parser.parse(expr, null, null);
try {
x = root.evaluate(null);
} catch (SSErrorXelException ex) {
assertEquals(SSError.NUM, ex.getSSError());
}
}