-
Notifications
You must be signed in to change notification settings - Fork 30k
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
test: add coverage for boxed bigints comparisons and edge cases #25932
Conversation
Add some BigInt tests for test-util-isDeepStrictEqual to get 100% coverage for lib/internal/util/comparisons.js.
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 first commit seems fine.
The checks however are not obsolete. Removing them would cause some input to throw a wrong error.
const a = new Number(5)
const b = new String(5)
Object.defineProperty(b, Symbol.toStringTag, { value: 'Number' })
Object.setPrototypeOf(b, Number.prototype)
util.isDeepStrictEqual(a, b)
// TypeError: Number.prototype.valueOf requires that 'this' be a Number
/ping @bcoe There seems to be a (known?) bug in the coverage reports. The code I removed from the ternaries in this PR always evaluates to EDIT: Since I updated the PR such that it's probably not clear what I'm talking about anymore: return foo && bar; If |
Ah, that's how you can do it! Thanks. We don't have any test cases for that sort of thing, but I'll remove that second commit and add a bunch to make sure we get every combination of values tested in those ternaries. |
Test for deep strict equality when prototype and toStringTag have been modified in surprising ways.
a45d0de
to
d89a32b
Compare
Modifications to |
@Trott if you don't mind, perhaps make a tracking issue and assign to me? could be a problem with the remapping logic. Is it specifically when there's a |
An issue was opened by @BridgeAR at #25937. I've assigned it to you.
I'll put a code example over in that issue along with |
Landed in f31794b...5d52c8e. |
Add some BigInt tests for test-util-isDeepStrictEqual to get 100% coverage for lib/internal/util/comparisons.js. PR-URL: nodejs#25932 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Test for deep strict equality when prototype and toStringTag have been modified in surprising ways. PR-URL: nodejs#25932 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Add some BigInt tests for test-util-isDeepStrictEqual to get 100% coverage for lib/internal/util/comparisons.js. PR-URL: #25932 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Test for deep strict equality when prototype and toStringTag have been modified in surprising ways. PR-URL: #25932 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
First commit:
Second commit:Second commit:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes