From 80af3d0468a226ba33a31e9e7ea64edbd11b0344 Mon Sep 17 00:00:00 2001 From: serso Date: Tue, 1 Nov 2011 01:34:26 +0400 Subject: [PATCH] degree support --- res/layout/calc_plus_button.xml | 1 + .../model/CalculatorEngineTest.java | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/res/layout/calc_plus_button.xml b/res/layout/calc_plus_button.xml index 3c976b70..17c9dbe6 100644 --- a/res/layout/calc_plus_button.xml +++ b/res/layout/calc_plus_button.xml @@ -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"/> \ No newline at end of file diff --git a/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java b/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java index f8fde86e..3b006d11 100644 --- a/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java +++ b/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java @@ -252,16 +252,21 @@ public class CalculatorEngineTest { } - /* @Test + @Test public void testDegrees() throws Exception { final CalculatorEngine cm = CalculatorEngine.instance; cm.setPrecision(3); - Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "°")); - Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "1°")); - 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°))")); + try { + Assert.assertEquals("0.017", cm.evaluate(JsclOperation.numeric, "°")); + fail(); + } catch (ParseException 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()); + + } }