tests fixed

This commit is contained in:
serso 2011-11-22 13:59:02 +04:00
parent cbfc8001c6
commit 1c78886cb8

View File

@ -129,11 +129,9 @@ public class CalculatorEngineTest {
fail(); fail();
} catch (ParseException e) { } catch (ParseException e) {
} }
try {
junit.framework.Assert.assertEquals("1", cm.evaluate(JsclOperation.numeric, "π/π!").getResult()); junit.framework.Assert.assertEquals("1", cm.evaluate(JsclOperation.numeric, "(π/π)!").getResult());
fail();
} catch (ParseException e) {
}
try { try {
junit.framework.Assert.assertEquals("i", cm.evaluate(JsclOperation.numeric, "(-1)i!").getResult()); junit.framework.Assert.assertEquals("i", cm.evaluate(JsclOperation.numeric, "(-1)i!").getResult());
fail(); fail();
@ -144,11 +142,16 @@ public class CalculatorEngineTest {
CalculatorEngine.instance.getVarsRegister().add(new Var.Builder("si", 5d)); CalculatorEngine.instance.getVarsRegister().add(new Var.Builder("si", 5d));
try {
cm.getEngine().setDefaultAngleUnits(AngleUnits.rad);
Assert.assertEquals("-0.959", cm.evaluate(JsclOperation.numeric, "sin(5)").getResult()); Assert.assertEquals("-0.959", cm.evaluate(JsclOperation.numeric, "sin(5)").getResult());
Assert.assertEquals("-4.795", cm.evaluate(JsclOperation.numeric, "sin(5)si").getResult()); Assert.assertEquals("-4.795", cm.evaluate(JsclOperation.numeric, "sin(5)si").getResult());
Assert.assertEquals("-23.973", cm.evaluate(JsclOperation.numeric, "sisin(5)si").getResult()); Assert.assertEquals("-23.973", cm.evaluate(JsclOperation.numeric, "sisin(5)si").getResult());
Assert.assertEquals("-23.973", cm.evaluate(JsclOperation.numeric, "si*sin(5)si").getResult()); Assert.assertEquals("-23.973", cm.evaluate(JsclOperation.numeric, "si*sin(5)si").getResult());
Assert.assertEquals("-3.309", cm.evaluate(JsclOperation.numeric, "sisin(5si)si").getResult()); Assert.assertEquals("-3.309", cm.evaluate(JsclOperation.numeric, "sisin(5si)si").getResult());
} finally {
cm.getEngine().setDefaultAngleUnits(defaultAngleUnits);
}
CalculatorEngine.instance.getVarsRegister().add(new Var.Builder("s", 1d)); CalculatorEngine.instance.getVarsRegister().add(new Var.Builder("s", 1d));
Assert.assertEquals("5", cm.evaluate(JsclOperation.numeric, "si").getResult()); Assert.assertEquals("5", cm.evaluate(JsclOperation.numeric, "si").getResult());
@ -239,7 +242,13 @@ public class CalculatorEngineTest {
} catch (ParseException e) { } catch (ParseException e) {
} }
final AngleUnits defaultAngleUnits = cm.getEngine().getDefaultAngleUnits();
try {
cm.getEngine().setDefaultAngleUnits(AngleUnits.rad);
Assert.assertEquals("0.739", cm.evaluate(JsclOperation.numeric, "cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(1))))))))))))))))))))))))))))))))))))").getResult()); Assert.assertEquals("0.739", cm.evaluate(JsclOperation.numeric, "cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(cos(1))))))))))))))))))))))))))))))))))))").getResult());
} finally {
cm.getEngine().setDefaultAngleUnits(defaultAngleUnits);
}
CalculatorEngine.instance.getVarsRegister().add(new Var.Builder("si", 5d)); CalculatorEngine.instance.getVarsRegister().add(new Var.Builder("si", 5d));
Assert.assertEquals("5", cm.evaluate(JsclOperation.numeric, "si").getResult()); Assert.assertEquals("5", cm.evaluate(JsclOperation.numeric, "si").getResult());