-
Notifications
You must be signed in to change notification settings - Fork 480
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
More thorough bigint relational comparison tests #1251
Conversation
4. Else, | ||
a. Let nx be ? ToNumeric(px). Because px and py are primitive values evaluation order is not important. | ||
b. Let ny be ? ToNumeric(py). | ||
c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). |
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.
You're hitting this case, right? If so, maybe the below spec text doesn't need to be quoted. Also, you could quote BigInt::lessThan, which is always hit here.
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.
Good catch. The frontmatter needs to be specialized for the different files even more than this. I'll make that update.
assert.sameValue(0x1fffffffffffff01n >= 0x1fffffffffffff02n, false); | ||
assert.sameValue(0x1fffffffffffff02n >= 0x1fffffffffffff01n, true); | ||
assert.sameValue(-0x1fffffffffffff01n >= -0x1fffffffffffff02n, true); | ||
assert.sameValue(-0x1fffffffffffff02n >= -0x1fffffffffffff01n, false); |
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.
Maybe test some more values, e.g., a combination of long and short BigInt values.
assert.sameValue(1n >= -Number.MAX_VALUE, true); | ||
assert.sameValue(-Number.MAX_VALUE >= 1n, false); | ||
assert.sameValue( | ||
0xfffffffffffff80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n >= Number.MAX_VALUE, |
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.
Would it make sense to have a test for the edge cases, namely the BigInt which represents one less than Number.MAX_VALUE, the BigInt which is Number.MAX_VALUE, and one greater than it?
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.
I addressed this in the OP of this PR, but it might be good to throw a comment in the file as well. What do you think?
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.
Sorry, I missed the explanation there. I disagree with your reading of the spec--I think Number.MAX_VALUE is well-defined.
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.
Alright, I'll tighten up the test.
Are you saying you can't achieve a thorough and consistent coverage this way? |
Sorry. I'm saying that I am achieving the same level of runtime coverage. Instead of runtime logic, I'm using analogous logic in the code generator. An example of this coverage is that the case of comparing |
Why not use the existing test generator tool? |
Please review the CI failures. The frontmatter is invalid.
|
c. If Type(nx) is Type(ny), return ? Type(nx)::lessThan(nx, ny). | ||
|
||
sec-numeric-types-bigint-lessThan | ||
BigInt::lessThan (x, y) |
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.
missing spaces, this is causing the yaml parsing to fail.
Oops. Should have known that was invalid yaml. |
If you're talking about |
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.
From this point, we can take care of nitpicks in follow up PRs.
LGTM.
Notably this introduces coverage for:
Infinity
andNaN
, which are special cases in the new algorithm.Number.MAX_VALUE
vs bigint values that are a little above and a little below it by a factor of 16.Number.MAX_SAFE_INTEGER
that only differ by1n
.Regarding
Number.MAX_VALUE
, my reading of the spec is that we should not test differing from that value by only1
, sinceNumber.MAX_VALUE
is an approximate value. However, a factor of 16 above and below seems far enough way that any reasonable approximation should recognize the difference.I'm trying a new approach to writing tests, where instead of using runtime abstraction to get thorough and consistent coverage, I'm using a python script to generate this code. I didn't include the generator script in this PR, because it seemed like a one-off thing that wouldn't be generally useful. If there is interest in including this generator in test262, here's what I've got so far, and I already know the style would need cleaning up to fit test262's style (e.g. indentation width).
The generator approach made it very easy to separate tests into 16 separate files. I could separate these tests into even more files pretty easily if that'd be desired. For example, I could put
Infinity
andNaN
into separate test files instead of the one file called-non-finite
.