This commit is contained in:
Sergey Solovyev 2011-11-17 17:50:14 +04:00
parent 4d679ddb80
commit 94282706fe
3 changed files with 12 additions and 2 deletions

View File

@ -9,6 +9,5 @@
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/functionsButton"
a:text="∂,∫"
a:textStyle="italic"
a:onClick="operatorsButtonClickHandler"
style="?controlButtonStyle"/>

View File

@ -105,6 +105,11 @@ public class TextHighlighter implements TextProcessor<TextHighlighter.Result> {
text1.append(text.charAt(i));
break;
case operator:
text1.append(mathType.getMatch());
if (mathType.getMatch().length() > 1) {
i += mathType.getMatch().length() - 1;
}
break;
case function:
i = processHighlightedText(text1, i, mathType.getMatch(), "i");
break;

View File

@ -81,7 +81,7 @@ public class CalculatorEngineTest {
Assert.assertEquals("0", cm.evaluate(JsclOperation.numeric, "eq(0, 1)").getResult());
Assert.assertEquals("1", cm.evaluate(JsclOperation.numeric, "eq(1, 1)").getResult());
Assert.assertEquals("1", cm.evaluate(JsclOperation.numeric, "eq( 1, 1)").getResult());
Assert.assertEquals("eq(1,1)", cm.evaluate(JsclOperation.simplify, "eq( 1, 1)").getResult());
Assert.assertEquals("1", cm.evaluate(JsclOperation.simplify, "eq( 1, 1)").getResult());
Assert.assertEquals("1", cm.evaluate(JsclOperation.numeric, "lg(10)").getResult());
Assert.assertEquals("4", cm.evaluate(JsclOperation.numeric, "2+2").getResult());
Assert.assertEquals("-0.757", cm.evaluate(JsclOperation.numeric, "sin(4)").getResult());
@ -184,6 +184,12 @@ public class CalculatorEngineTest {
cm.setTimeout(3000);
}*/
CalculatorEngine.instance.getVarsRegister().add(new Var.Builder("t", (String) null));
Assert.assertEquals("2t", cm.evaluate(JsclOperation.simplify, "∂(t^2,t)").getResult());
Assert.assertEquals("2t", cm.evaluate(JsclOperation.numeric, "∂(t^2,t)").getResult());
CalculatorEngine.instance.getVarsRegister().add(new Var.Builder("t", "2"));
Assert.assertEquals("2t", cm.evaluate(JsclOperation.simplify, "∂(t^2,t)").getResult());
Assert.assertEquals("4", cm.evaluate(JsclOperation.numeric, "∂(t^2,t)").getResult());
}
@Test