-
Notifications
You must be signed in to change notification settings - Fork 119
Comprehensive jsnum tests #1818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: horizon
Are you sure you want to change the base?
Conversation
…t exercised by Pyret
- fromString(): for non-negative-exp sci not, avoid a division
- js-numbers.js returns _innards to allow more testing
- liftFixnumInteger: should produce valid Rational boxnum
- add test for toRepeatingDecimal
- test toStringDigits
- correct isInteger() def
tests/jsnums-test/jsnums-test.js
Outdated
expect(JN.fromString("1e140", sampleErrorBacks)).toEqual(JN.makeBignum("1e140")); | ||
|
||
// for large bignums (> 1e140 ?), fromString() and makeBignum() can give structurally | ||
// unequal results. so the following fail: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ds26gte why are these commented out? We should be testing to make sure they fail, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that they should not fail, but were. I kept them around so I could solve the underlying problem as to why they were failing.
Now that I've canonicalized bigint representation -- i.e, every bigint now has a only one representation, not multiple as before --, these tests no longer fail, and are now uncommented.
- ensure integerNthRoot() is monotonically nondecreasing brownplt#1822 - require integerNthRoot() root and radicand to be non-neg - require nthRoot() root to be non-neg
** should remove fields at .t and above ** should remove any trailing zero fields, also reducing .t - bnDivide() should call clamp()
- test: bnToString _integerIsZero _integerIsOne _integerGcd
- bnpD{L,R}ShiftTo() should canonicalize
- test for: makeInteger{UnOp,Binop} - test for: bnpAddTo bnpDMultiply bnpMillerRabin - test for: bnRemainder bnModPow bnDivideAndRemainder bnIsProbablePrime
While adding tests, found the following corrections that needed to be applied to
|
- toRational() methods take errbacks param even tho they don't use them
- runtime.js: gcd, lcm simplified as variable num args unneeded - add num-lcm also - image-lib.js: use simplified gcd - tests for num-gcd, num-lcm
This in-progress PR addresses Issue #1812.
A JS test file
tests/jsnums-test/jsnums-test.c
will test the methods and functions defined injs-numbers.js
(Pyret's number library) that cannot be adequately tested by Pyret test files such astests/pyret/tests/test-numbers.js
.This PR is WIP, and not ready to merge yet.