test: test bottom-up merge sort in URLSearchParams#11399
test: test bottom-up merge sort in URLSearchParams#11399watilde wants to merge 1 commit intonodejs:masterfrom
Conversation
There was a problem hiding this comment.
If I am reading correctly the test part below just duplicates the code above? Then we can probably just construct the params first and then put it in the array literal that's being forEached above?
There was a problem hiding this comment.
That's nice. I've updated it :)
e653c27 to
cca745a
Compare
There was a problem hiding this comment.
Hmm..so looks like this doesn't actually catch a mistake in the implementation because we are sorting identical pairs...maybe we can generate the keys on the fly, pseudo-shuffle them, then compared to another original copy to make sure they are sorted properly?
const tests = [{input: '', output: []}];
const pairs = [];
for (let i = 10; i < 60; i++) {
pairs.push([`a${i}`, 'b']);
tests[0].output.push([`a${i}`, 'b']);
}
tests[0].input = pairs.sort(() => Math.random() > 0.5).map((pair) => pair.join('=')).join('&');There was a problem hiding this comment.
That's right indeed. To use the random list to sort them actually, I've updated it with your comment. Thanks!
cca745a to
461fea7
Compare
There was a problem hiding this comment.
nit: I'd be more comfortable if there are more than just the threshold number of elements in pairs
There was a problem hiding this comment.
It sounds good to me as well. I will replace 60 with 100 later :)
The bottom-up iterative stable merge sort is called only when the length of provided value is larger than 100. Added a test for it.
461fea7 to
8176dc3
Compare
|
CI failures are unrelated. |
The bottom-up iterative stable merge sort is called only when the length of provided value is larger than 100. Added a test for it. PR-URL: #11399 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
|
Landed in 1b31ca6 |
The bottom-up iterative stable merge sort is called only when the length of provided value is larger than 100. Added a test for it. PR-URL: nodejs#11399 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Following up for this commit: 02d1e32 to increase the reduced coverage. The bottom-up iterative stable merge sort is called only when the length of provided value is larger than 100. Added a test for it.
This increases the coverage of
internal/url.js,and the following lines will be covered.
node/lib/internal/url.js
Lines 701 to 727 in e4e7cd5
node/lib/internal/url.js
Lines 886 to 900 in e4e7cd5
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test