Module operator fix
This commit is contained in:
@@ -35,6 +35,7 @@ import butterknife.ButterKnife;
|
||||
import com.squareup.otto.Bus;
|
||||
import jscl.NumeralBase;
|
||||
import jscl.math.Generic;
|
||||
import jscl.math.NotDoubleException;
|
||||
import org.solovyev.android.calculator.converter.ConverterFragment;
|
||||
import org.solovyev.android.calculator.jscl.JsclOperation;
|
||||
|
||||
@@ -134,8 +135,10 @@ public class DisplayFragment extends BaseFragment implements View.OnClickListene
|
||||
addMenu(menu, item.title, this);
|
||||
}
|
||||
}
|
||||
if (result.toDouble() != null) {
|
||||
try {
|
||||
result.doubleValue();
|
||||
addMenu(menu, R.string.c_convert, this);
|
||||
} catch (NotDoubleException ignored) {
|
||||
}
|
||||
}
|
||||
if (launcher.canPlot(result)) {
|
||||
@@ -207,10 +210,10 @@ public class DisplayFragment extends BaseFragment implements View.OnClickListene
|
||||
if (result == null) {
|
||||
return 1d;
|
||||
}
|
||||
final Double value = result.toDouble();
|
||||
if (value == null) {
|
||||
try {
|
||||
return result.doubleValue();
|
||||
} catch (NotDoubleException ignored) {
|
||||
return 1d;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -37,6 +38,8 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
|
||||
@RunWith(value = RobolectricGradleTestRunner.class)
|
||||
public class AndroidEditorViewTest {
|
||||
@@ -52,6 +55,7 @@ public class AndroidEditorViewTest {
|
||||
final int count = 10;
|
||||
final int maxTextLength = 100;
|
||||
|
||||
final Editor editor = new Editor(RuntimeEnvironment.application, mock(SharedPreferences.class), Tests.makeEngine());
|
||||
final Random random = new Random(new Date().getTime());
|
||||
final CountDownLatch startLatchLatch = new CountDownLatch(threadNum);
|
||||
final CountDownLatch finishLatch = new CountDownLatch(threadNum * count);
|
||||
@@ -75,7 +79,7 @@ public class AndroidEditorViewTest {
|
||||
for (int j = 0; j < count; j++) {
|
||||
try {
|
||||
int textLength = random.nextInt(maxTextLength);
|
||||
App.getEditor().insert(Strings.generateRandomString(textLength), textLength);
|
||||
editor.insert(Strings.generateRandomString(textLength), textLength);
|
||||
} catch (Throwable e) {
|
||||
System.out.println(e);
|
||||
error.set(true);
|
||||
|
@@ -30,6 +30,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricGradleTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -42,7 +43,7 @@ public class EditorTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
editor = new Editor(mock(SharedPreferences.class), Tests.makeEngine());
|
||||
editor = new Editor(RuntimeEnvironment.application, mock(SharedPreferences.class), Tests.makeEngine());
|
||||
editor.bus = mock(Bus.class);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user