Skip to content

Commit

Permalink
test: test bottom-up merge sort in URLSearchParams
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
watilde authored and italoacasas committed Feb 25, 2017
1 parent ff927b2 commit f5b4849
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/parallel/test-whatwg-url-searchparams-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,25 @@ const { test, assert_array_equals } = common.WPT;
/* eslint-enable */

// Tests below are not from WPT.
;[

// Test bottom-up iterative stable merge sort
const tests = [{input: '', output: []}];
const pairs = [];
for (let i = 10; i < 100; 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('&');

tests.push(
{
'input': 'z=a&=b&c=d',
'output': [['', 'b'], ['c', 'd'], ['z', 'a']]
}
].forEach((val) => {
);

tests.forEach((val) => {
test(() => {
const params = new URLSearchParams(val.input);
let i = 0;
Expand Down

0 comments on commit f5b4849

Please sign in to comment.