Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: test bottom-up merge sort in URLSearchParams
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.
  • Loading branch information
watilde committed Feb 16, 2017
commit 8176dc37aba89e233442a52d055784aeeb5cdf20
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