Version update + test fixed

This commit is contained in:
Sergey Solovyev 2012-11-18 01:33:24 +04:00
parent e1727bc23e
commit 5d82657274
5 changed files with 40 additions and 22 deletions

View File

@ -39,10 +39,10 @@ public class ListCalculatorEventContainer implements CalculatorEventContainer {
public void fireCalculatorEvents(@NotNull List<CalculatorEvent> calculatorEvents) {
final List<CalculatorEventListener> listeners = this.listeners.getListeners();
final CalculatorLogger logger = CalculatorLocatorImpl.getInstance().getLogger();
//final CalculatorLogger logger = CalculatorLocatorImpl.getInstance().getLogger();
for (CalculatorEvent e : calculatorEvents) {
CalculatorLocatorImpl.getInstance().getLogger().debug(TAG, "Event fired: " + e.getCalculatorEventType());
//CalculatorLocatorImpl.getInstance().getLogger().debug(TAG, "Event fired: " + e.getCalculatorEventType());
for (CalculatorEventListener listener : listeners) {
/*long startTime = System.currentTimeMillis();*/
listener.onCalculatorEvent(e.getCalculatorEventData(), e.getCalculatorEventType(), e.getData());

View File

@ -6,11 +6,12 @@
package org.solovyev.android.calculator;
import jscl.math.function.Function;
import jscl.math.function.IConstant;
import org.jetbrains.annotations.NotNull;
import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.text.TextProcessor;
import org.solovyev.common.StartsWithFinder;
import org.solovyev.android.calculator.math.MathType;
import org.solovyev.common.collections.CollectionsUtils;
import org.solovyev.common.msg.MessageType;
@ -72,6 +73,16 @@ public class ToJsclTextProcessor implements TextProcessor<PreparedExpression, St
}
}
if (mathTypeBefore != null &&
(mathTypeBefore.getMathType() == MathType.function || mathTypeBefore.getMathType() == MathType.operator) &&
CollectionsUtils.find(MathType.openGroupSymbols, startsWithFinder) != null) {
final String functionName = mathTypeBefore.getMatch();
final Function function = CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry().get(functionName);
if ( function == null || function.getMinParameters() > 0 ) {
throw new CalculatorParseException(i, s, new CalculatorMessage(CalculatorMessages.msg_005, MessageType.error, mathTypeBefore.getMatch()));
}
}
i = mathTypeResult.processToJscl(result, i);
}
return result;

View File

@ -207,10 +207,10 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest {
try {
cm.setNumeralBase(NumeralBase.hex);
CalculatorTestUtils.assertEval("E/F", "0x:E/0x:F");
CalculatorTestUtils.assertEval("E/F", cm.simplify( "0x:E/0x:F"));
CalculatorTestUtils.assertEval("E/F", "E/F");
CalculatorTestUtils.assertEval("E/F", cm.simplify( "E/F"));
CalculatorTestUtils.assertEval("0.EE E", "0x:E/0x:F");
CalculatorTestUtils.assertEval("0.EE E", cm.simplify( "0x:E/0x:F"));
CalculatorTestUtils.assertEval("0.EE E", "E/F");
CalculatorTestUtils.assertEval("0.EE E", cm.simplify( "E/F"));
} finally {
cm.setNumeralBase(NumeralBase.dec);
}
@ -396,7 +396,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest {
try{
cm.setNumeralBase(NumeralBase.bin);
CalculatorTestUtils.assertEval("101", "10+11");
CalculatorTestUtils.assertEval("10/11", "10/11");
CalculatorTestUtils.assertEval("0.101", "10/11");
cm.setNumeralBase(NumeralBase.hex);
CalculatorTestUtils.assertEval("63 7B", "56CE+CAD");

View File

@ -6,9 +6,11 @@ import org.hamcrest.Description;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
import org.solovyev.android.calculator.CalculatorTestUtils;
import org.solovyev.common.equals.CollectionEqualizer;
import org.solovyev.common.equals.EqualsUtils;
import org.solovyev.common.text.StringUtils;
@ -58,6 +60,11 @@ public class FunctionsTest {
" </functions>\n" +
"</functions>";
@Before
public void setUp() throws Exception {
CalculatorTestUtils.staticSetUp();
}
@Test
public void testXml() throws Exception {
final Functions in = new Functions();

View File

@ -9,19 +9,19 @@
# Project target.
target=android-15
android.library.reference.1=gen-external-apklibs/org.solovyev.android_android-common-all_1.0.5-SNAPSHOT
android.library.reference.2=gen-external-apklibs/org.solovyev.android_android-common-ads_1.0.5-SNAPSHOT
android.library.reference.3=gen-external-apklibs/org.solovyev.android_android-common-core_1.0.5-SNAPSHOT
android.library.reference.4=gen-external-apklibs/org.solovyev.android_android-common-billing_1.0.5-SNAPSHOT
android.library.reference.5=gen-external-apklibs/org.solovyev.android_android-common-db_1.0.5-SNAPSHOT
android.library.reference.6=gen-external-apklibs/org.solovyev.android_android-common-http_1.0.5-SNAPSHOT
android.library.reference.7=gen-external-apklibs/org.solovyev.android_android-common-list_1.0.5-SNAPSHOT
android.library.reference.8=gen-external-apklibs/org.solovyev.android_android-common-view_1.0.5-SNAPSHOT
android.library.reference.9=gen-external-apklibs/org.solovyev.android_android-common-preferences_1.0.5-SNAPSHOT
android.library.reference.10=gen-external-apklibs/org.solovyev.android_android-common-menu_1.0.5-SNAPSHOT
android.library.reference.11=gen-external-apklibs/org.solovyev.android_android-common-other_1.0.5-SNAPSHOT
android.library.reference.12=gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.0.5-SNAPSHOT
android.library.reference.1=gen-external-apklibs/org.solovyev.android_android-common-all_1.0.5
android.library.reference.2=gen-external-apklibs/org.solovyev.android_android-common-ads_1.0.5
android.library.reference.3=gen-external-apklibs/org.solovyev.android_android-common-core_1.0.5
android.library.reference.4=gen-external-apklibs/org.solovyev.android_android-common-billing_1.0.5
android.library.reference.5=gen-external-apklibs/org.solovyev.android_android-common-db_1.0.5
android.library.reference.6=gen-external-apklibs/org.solovyev.android_android-common-http_1.0.5
android.library.reference.7=gen-external-apklibs/org.solovyev.android_android-common-list_1.0.5
android.library.reference.8=gen-external-apklibs/org.solovyev.android_android-common-view_1.0.5
android.library.reference.9=gen-external-apklibs/org.solovyev.android_android-common-preferences_1.0.5
android.library.reference.10=gen-external-apklibs/org.solovyev.android_android-common-menu_1.0.5
android.library.reference.11=gen-external-apklibs/org.solovyev.android_android-common-other_1.0.5
android.library.reference.12=gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.0.5
android.library.reference.13=gen-external-apklibs/com.actionbarsherlock_actionbarsherlock_4.2.0
android.library.reference.14=gen-external-apklibs/org.solovyev.android_android-common-keyboard_1.0.5-SNAPSHOT
android.library.reference.14=gen-external-apklibs/org.solovyev.android_android-common-keyboard_1.0.5