diff options
author | Hans Boehm <hboehm@google.com> | 2015-05-31 12:19:05 -0700 |
---|---|---|
committer | Hans Boehm <hboehm@google.com> | 2015-06-02 11:51:09 -0700 |
commit | 4db31b490443e4454d98a5ae2bc44b87149accfe (patch) | |
tree | 9843640804505c092ea1f883928b5871f7b56591 /tests | |
parent | e125edff83b7f73cadaa7a0a007cccec6bd059b2 (diff) | |
download | android_packages_apps_ExactCalculator-4db31b490443e4454d98a5ae2bc44b87149accfe.tar.gz android_packages_apps_ExactCalculator-4db31b490443e4454d98a5ae2bc44b87149accfe.tar.bz2 android_packages_apps_ExactCalculator-4db31b490443e4454d98a5ae2bc44b87149accfe.zip |
Implement percent and new inverse functions
Bug: 21493470
Add x^2 10^x and e^x functions, to make the recently added INV key
work as expected.
Implement % functionality.
10^x is essentially just macro expansions for now.
% and x^2 need trivial evaluator support to provide reasonable display
syntax.
We decided to add evaluator support for exp() as well.
Add corresponding exp() support to BoundedRational and its tests.
Tiny incidental changes for problems uncovered in the process:
Fix bug in tests/README.txt
Evaluate the constant e only once.
Add one more power test along with the exp() test.
Fix proguard.flags so BRTest runs again.
Change-Id: I26cfcaf6d99aeec11387297cc5586e2ddcab6add
Diffstat (limited to 'tests')
-rw-r--r-- | tests/README.txt | 2 | ||||
-rw-r--r-- | tests/src/com/android/calculator2/BRTest.java | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/tests/README.txt b/tests/README.txt index 3069de8..b1cd968 100644 --- a/tests/README.txt +++ b/tests/README.txt @@ -2,7 +2,7 @@ Run on Android with 1) Build the tests. 2) Install the calculator with -adb install <tree root>/out/target/product/generic/data/app/ExactCalculatorTests/ExactCalculator.apk +adb install <tree root>/out/target/product/generic/data/app/ExactCalculator/ExactCalculator.apk 3) adb install <tree root>/out/target/product/generic/data/app/ExactCalculatorTests/ExactCalculatorTests.apk 4) adb shell am instrument -w com.android.exactcalculator.tests/android.test.InstrumentationTestRunner diff --git a/tests/src/com/android/calculator2/BRTest.java b/tests/src/com/android/calculator2/BRTest.java index 1cd56a5..29a5ae9 100644 --- a/tests/src/com/android/calculator2/BRTest.java +++ b/tests/src/com/android/calculator2/BRTest.java @@ -92,6 +92,13 @@ public class BRTest extends TestCase { } catch (ArithmeticException ignored) { check((long_x - 90) % 180 == 0, "exception on defined tan: " + x); } + if (x.compareTo(BoundedRational.THIRTY) <= 0 + && x.compareTo(BoundedRational.MINUS_THIRTY) >= 0) { + checkWeakEq(BoundedRational.exp(x), xAsCR.exp(), "exp:" + x); + checkWeakEq(BoundedRational.pow(BR_15, x), + CR.valueOf(15).ln().multiply(xAsCR).exp(), + "pow(15,x):" + x); + } if (x.compareTo(BoundedRational.ONE) <= 0 && x.compareTo(BoundedRational.MINUS_ONE) >= 0) { checkWeakEq(BoundedRational.asin(x), ASIN.execute(xAsCR), |