degree support

This commit is contained in:
serso 2011-11-01 01:34:26 +04:00
parent 9ac53cc053
commit 80af3d0468
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"
a:id="@+id/plusButton"
calc:directionTextScale="0.5"
calc:textUp="°"
a:text="+"
style="?digitButtonStyle"
a:onClick="digitButtonClickHandler"/>

View File

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