degree support

This commit is contained in:
serso 2011-11-01 01:34:26 +04:00
parent 457cb4db0c
commit 4312f7c475
2 changed files with 13 additions and 7 deletions

View File

@ -9,6 +9,7 @@
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator" xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/plusButton" a:id="@+id/plusButton"
calc:directionTextScale="0.5" calc:directionTextScale="0.5"
calc:textUp="°"
a:text="+" a:text="+"
style="?digitButtonStyle" style="?digitButtonStyle"
a:onClick="digitButtonClickHandler"/> a:onClick="digitButtonClickHandler"/>

View File

@ -252,16 +252,21 @@ public class CalculatorEngineTest {
} }
/* @Test @Test
public void testDegrees() throws Exception { public void testDegrees() throws Exception {
final CalculatorEngine cm = CalculatorEngine.instance; final CalculatorEngine cm = CalculatorEngine.instance;
cm.setPrecision(3); cm.setPrecision(3);
try {
Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "°")); Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "°"));
Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "")); fail();
Assert.assertEquals("0.349", cm.evaluate(JsclOperation.numeric, "20.0°")); } catch (ParseException e) {
Assert.assertEquals("0.5", cm.evaluate(JsclOperation.numeric, "sin(30°)"));
Assert.assertEquals("0.524", cm.evaluate(JsclOperation.numeric, "asin(sin(30°))"));
}*/ }
Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "").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());
}
} }