From 927123460596bd4ef0a8241a09422efe0574c639 Mon Sep 17 00:00:00 2001 From: serso Date: Mon, 21 Nov 2011 15:11:36 +0400 Subject: [PATCH] imaginary number in jscl --- .../jscl/FromJsclNumericTextProcessor.java | 13 +++++-------- .../calculator/model/CalculatorEngineTest.java | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/solovyev/android/calculator/jscl/FromJsclNumericTextProcessor.java b/src/main/java/org/solovyev/android/calculator/jscl/FromJsclNumericTextProcessor.java index 5c0102b9..7cf48cca 100644 --- a/src/main/java/org/solovyev/android/calculator/jscl/FromJsclNumericTextProcessor.java +++ b/src/main/java/org/solovyev/android/calculator/jscl/FromJsclNumericTextProcessor.java @@ -34,14 +34,11 @@ class FromJsclNumericTextProcessor implements TextProcessor { } } catch (NumberFormatException e) { result = result.replace(MathType.INFINITY_JSCL, MathType.INFINITY); - if (result.contains(MathType.IMAGINARY_NUMBER_JSCL)) { - try { - result = createResultForComplexNumber(result.replace(MathType.IMAGINARY_NUMBER_JSCL, MathType.IMAGINARY_NUMBER)); - } catch (NumberFormatException e1) { - // throw original one - throw new ParseException(e); - } - + try { + result = createResultForComplexNumber(result.replace(MathType.IMAGINARY_NUMBER_JSCL, MathType.IMAGINARY_NUMBER)); + } catch (NumberFormatException e1) { + // throw original one + throw new ParseException(e); } } 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 b9987887..0ac63a77 100644 --- a/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java +++ b/src/test/java/org/solovyev/android/calculator/model/CalculatorEngineTest.java @@ -130,7 +130,7 @@ public class CalculatorEngineTest { } catch (ParseException e) { } try { - junit.framework.Assert.assertEquals("i", cm.evaluate(JsclOperation.numeric, "π/π!").getResult()); + junit.framework.Assert.assertEquals("1", cm.evaluate(JsclOperation.numeric, "π/π!").getResult()); fail(); } catch (ParseException e) { }