summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Fix factorial(0)" into mnc-dr-devHans Boehm2015-10-113-2/+6
|\
| * Fix factorial(0)Hans Boehm2015-10-093-2/+6
| | | | | | | | | | | | | | | | | | | | | | Bug: 24575798 Make factorial(0) return 1, as intended. Add a few factorial tests. Fix targetPackage spec so test is actually runnable again. Change-Id: Ibb8d827f0325999c6b5ed49a939e1532ddf55639 (cherry picked from commit 6951591806f46405564a6cb868a88d0daf6764d2)
* | Check for decimal point after adding ellipsisHans Boehm2015-10-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 23728152 This avoids the one case in which we displayed neither a decimal point nor an exponent, and the decimal point was not just to the right of the number. Remove a redundant test, which obscured the logic. Add a couple of suggested manual tests that helped me find a (newly introduced, not submitted) bug. Change-Id: Iead1efa0a4e8ea74512e9e1f77334f80bbcdd202 (cherry picked from commit 73ecff20d9dfd80d1cff09e0210d8987049b9df3)
* | Address FIXME comments from previous cleanup CLHans Boehm2015-10-102-2/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 24811759 Bug: 22047258 Add code to actively prevent ...99999 from getting turned back into ...00000 . This may have been imposssible anyway, but I couldn't prove it. Add tests for some Evaluator static functions, including the new unflipZeroes(). Fix a minor bug in exponentEnd() discovered in the process. The logic for limiting exponent length was wrong. Remove some no longer needed code to force a reevaluation. Generalize getPadding() function to repeat() and make it static. Remove leadingZeroes() which is no longer used. Make getMsdIndex() return the correct result even if it has changed due to reevaluation. Change-Id: Id457d8327ce0bc184d72ef78ddd3dbdaab7c6c78 (cherry picked from commit 7a432880b9d42b91a7069c6fb5398470f3cff19e)
* | BoundedRational.java cleanupHans Boehm2015-10-091-0/+6
|/ | | | | | | | | | | | | | | | | | | | | | Bug: 24811759 Bug: 21469726 Bug: 23080519 Reformat to 100 columns. Reformat simple if-statements and rename variables for better consistency with coding conventions. Switch many comments to javadoc style. Consistently use signum() to compare to zero. It's more concise and probably slightly more efficient. Change the asBigInteger implementation to use a single divideAndRemainder call instead of relying on gcd. Add tests. Eliminate redundant test in maybeReduce(). Change-Id: I4c275494e076612d09a05bc317c9972008619cda (cherry picked from commit a4511f349124ca9cd2a7f9cb742be02b832a0206)
* Correct off-by-1 errors in display formatting code.Hans Boehm2015-06-231-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 21986868 Bug: 21960281 Fix and restructure the formatting and scroll-limit-calculation code. This code is inherently tricky, and has had more bugs than we would like to admit to. Use the opportunity to clean up the code a bit, renaming variables consistently. The good news is that the code seems to be getting slightly simpler with each bug fix. This fixes several separate off-by-one errors related to result formatting: The expLen() exponent string length calculation was off by 1 for exact powers of 10. The dropDigits calculation in the formatting code was off for negative exponents just shorter than an exact power of 10. The exponent space calculation for a few results like -1.2*10^-8 was off by one. For a result like -10^-500 we did not reserve space for the leading minus sign, since that's not computed until after scrolling. [Less serious] The ellipses were omitted when we had just barely scrolled a leading minus sign off the screen. (This only occurred in exactly one position, which could never be the default one.) Change-Id: If1bfbbb70a624998be3d996592d129b16aade745
* Fix digitsRequired() for negative denominatorsHans Boehm2015-06-131-0/+6
| | | | | | | | | Bug: 21789679 Also adds some tests for digitsRequired(), including one that fails without this CL. Change-Id: Ib007e753f90c019c37666d71c1cfd02301dcd360
* Implement percent and new inverse functionsHans Boehm2015-06-022-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Prepare ExactCalculator for master fishfoodJustin Klaassen2015-04-162-14/+5
| | | | | | | | - Switched back to using com.android.calculator2 package name. - Setup to replace Calculator package. - Replaced launcher icon with fishfood variant. Change-Id: Ie3a74249e4d1808c50bfd86a3030e0ae61165c67
* Fix UI holes and bugs. Fix eval bugs.Hans Boehm2015-04-153-27/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change layout to make the result display use a fixed font size and limit the number of characters when it appears below the formula. This allows us to always get the proper expansion effect and prevents scrolling from affecting the font size. Add copy support for result display. Add paste support for the formula. Add keyboard input support. Copy/paste can be used to remember old results in the calculator. We save an identifying tag URI in the clip, in addition to text, allowing us to paste old calculator results without precision loss. Copy/paste currently does not rely on selection at all. I had trouble making it work that way in the formula. It's unclear that would be better, since we only allow copy of the entire text and paste at the end. Add a couple of alternate result display options to the overflow menu. (These appear quite useful, were trivial to implement, and give us a better excuse for the overflow menu.) Changed the behavior of the delete key in error state. Changing it to CLEAR seemed unfriendly, since it prevents corrections. This is a change from L. Made it clear that the CalculatorHitSomeButtons test is currently 95% worthless. It was apparentlly failing (due to test infrastructure issues) but throwing an exception in a thread from which it was not getting reported. Decided to keep it, since I would like a place to continue collecting regression tests, even if we can't actually run them yet. Includes some easy drive-by fixes for expression evaluation: a) 2 / 2 * 3 was mis-parsed as 2 / (2 * 3). b) Cosine evaluation had the sense of the test for a rational result reversed. c) Constants without leading digits, like .1, are now handled correctly, and decimal points in the formula are now internationalized. (That's not yet true for the result.) Change-Id: Ic24466b444b4a4633cfb036c67622c7f4fd644ec
* Add tests, fix BoundedRational bugsHans Boehm2015-04-075-0/+433
| | | | | | | | | | | | | Add back some basic test infrastructure from the KitKat calculator, updated to make it work with the current code base and asynchronous expression evaluation. Add BoundedRational tests, designed to check that we get all the corner cases, particularly for degree-based trig functions, right. Fix a couple of BoundedRational typos that caused these tests to fail. Change-Id: I81d8f3d9bde6aa6c20f9958eabd62979babeff5b
* Overhaul Calculator UI.Justin Klaassen2014-05-285-284/+0
| | | | | | | | | | | | | | | | Bug: 14418545 Bug: 14419084 Bug: 14419142 Bug: 14420277 Bug: 14466652 Bug: 14564559 Bug: 14564608 Bug: 14846724 Bug: 15090154 Bug: 15287699 Bug: 15289526 Bug: 15289616 Change-Id: I93e1530446d5bd6a4c3189f751c88ece1abc7767
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-035-0/+284
|
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-035-284/+0
|
* Code drop from //branches/cupcake/...@124589The Android Open Source Project2008-12-174-0/+186
|
* Initial ContributionThe Android Open Source Project2008-10-213-0/+98