test fixes
This commit is contained in:
parent
b1c813e63d
commit
8d6d6bc044
@ -36,6 +36,33 @@ public class CalculatorEngineTest {
|
||||
CalculatorEngine.instance.setThreadKiller(new CalculatorEngine.ThreadKillerImpl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDegrees() throws Exception {
|
||||
final CalculatorEngine cm = CalculatorEngine.instance;
|
||||
|
||||
final AngleUnit defaultAngleUnit = cm.getEngine().getAngleUnits();
|
||||
try {
|
||||
cm.getEngine().setAngleUnits(AngleUnit.rad);
|
||||
cm.setPrecision(3);
|
||||
try {
|
||||
Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "°"));
|
||||
fail();
|
||||
} catch (CalculatorParseException e) {
|
||||
|
||||
}
|
||||
|
||||
Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "1°").getResult());
|
||||
Assert.assertEquals("0.349", cm.evaluate(JsclOperation.numeric, "20.0°").getResult());
|
||||
Assert.assertEquals("0.5", cm.evaluate(JsclOperation.numeric, "sin(30°)").getResult());
|
||||
Assert.assertEquals("0.524", cm.evaluate(JsclOperation.numeric, "asin(sin(30°))").getResult());
|
||||
Assert.assertEquals("∂(cos(t), t, t, 1°)", cm.evaluate(JsclOperation.numeric, "∂(cos(t),t,t,1°)").getResult());
|
||||
|
||||
Assert.assertEquals("∂(cos(t), t, t, 1°)", cm.evaluate(JsclOperation.simplify, "∂(cos(t),t,t,1°)").getResult());
|
||||
} finally {
|
||||
cm.getEngine().setAngleUnits(defaultAngleUnit);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongExecution() throws Exception {
|
||||
final CalculatorEngine cm = CalculatorEngine.instance;
|
||||
@ -379,32 +406,4 @@ public class CalculatorEngineTest {
|
||||
cm.setNumeralBase(defaultNumeralBase);
|
||||
}
|
||||
}
|
||||
|
||||
/* @Test
|
||||
public void testDegrees() throws Exception {
|
||||
final CalculatorEngine cm = CalculatorEngine.instance;
|
||||
|
||||
final AngleUnit defaultAngleUnit = cm.getEngine().getAngleUnits();
|
||||
try {
|
||||
cm.getEngine().setAngleUnits(AngleUnit.rad);
|
||||
cm.setPrecision(3);
|
||||
try {
|
||||
Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "°"));
|
||||
fail();
|
||||
} catch (CalculatorParseException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "1°").getResult());
|
||||
Assert.assertEquals("0.349", cm.evaluate(JsclOperation.numeric, "20.0°").getResult());
|
||||
Assert.assertEquals("0.5", cm.evaluate(JsclOperation.numeric, "sin(30°)").getResult());
|
||||
Assert.assertEquals("0.524", cm.evaluate(JsclOperation.numeric, "asin(sin(30°))").getResult());
|
||||
Assert.assertEquals("∂(cos(t), t, t, 1°)", cm.evaluate(JsclOperation.numeric, "∂(cos(t),t,t,1°)").getResult());
|
||||
|
||||
Assert.assertEquals("∂(cos(t), t, t, 1°)", cm.evaluate(JsclOperation.simplify, "∂(cos(t),t,t,1°)").getResult());
|
||||
} finally {
|
||||
cm.getEngine().setAngleUnits(defaultAngleUnit);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ public class NumeralBaseTest {
|
||||
input.add(hex);
|
||||
input.add(bin);
|
||||
|
||||
System.out.println("Dec: " + dec);
|
||||
System.out.println("Hex: " + hex);
|
||||
System.out.println("Bin: " + bin);
|
||||
//System.out.println("Dec: " + dec);
|
||||
//System.out.println("Hex: " + hex);
|
||||
//System.out.println("Bin: " + bin);
|
||||
|
||||
final ExpressionGeneratorWithInput eg = new ExpressionGeneratorWithInput(input, 20);
|
||||
final List<String> expressions = eg.generate();
|
||||
@ -69,18 +69,18 @@ public class NumeralBaseTest {
|
||||
final String hexExpression = expressions.get(1);
|
||||
final String binExpression = expressions.get(2);
|
||||
|
||||
System.out.println("Dec expression: " + decExpression);
|
||||
System.out.println("Hex expression: " + hexExpression);
|
||||
System.out.println("Bin expression: " + binExpression);
|
||||
//System.out.println("Dec expression: " + decExpression);
|
||||
//System.out.println("Hex expression: " + hexExpression);
|
||||
//System.out.println("Bin expression: " + binExpression);
|
||||
|
||||
final String decResult = Expression.valueOf(decExpression).numeric().toString();
|
||||
System.out.println("Dec result: " + decResult);
|
||||
//System.out.println("Dec result: " + decResult);
|
||||
|
||||
final String hexResult = Expression.valueOf(hexExpression).numeric().toString();
|
||||
System.out.println("Hex result: " + hexResult);
|
||||
//System.out.println("Hex result: " + hexResult);
|
||||
|
||||
final String binResult = Expression.valueOf(binExpression).numeric().toString();
|
||||
System.out.println("Bin result: " + binResult);
|
||||
//System.out.println("Bin result: " + binResult);
|
||||
|
||||
Assert.assertEquals("dec-hex: " + decExpression + " : " + hexExpression, decResult, hexResult);
|
||||
Assert.assertEquals("dec-bin: " + decExpression + " : " + binExpression, decResult, binResult);
|
||||
|
Loading…
Reference in New Issue
Block a user