1'use strict'; 2 3// Tests below are not from WPT. 4 5require('../common'); 6const assert = require('assert'); 7const util = require('util'); 8 9const sp = new URLSearchParams('?a=a&b=b&b=c'); 10assert.strictEqual(util.inspect(sp), 11 "URLSearchParams { 'a' => 'a', 'b' => 'b', 'b' => 'c' }"); 12assert.strictEqual(util.inspect(sp, { depth: -1 }), '[Object]'); 13assert.strictEqual( 14 util.inspect(sp, { breakLength: 1 }), 15 "URLSearchParams {\n 'a' => 'a',\n 'b' => 'b',\n 'b' => 'c' }" 16); 17assert.strictEqual(util.inspect(sp.keys()), 18 "URLSearchParams Iterator { 'a', 'b', 'b' }"); 19assert.strictEqual(util.inspect(sp.values()), 20 "URLSearchParams Iterator { 'a', 'b', 'c' }"); 21assert.strictEqual(util.inspect(sp.keys(), { breakLength: 1 }), 22 "URLSearchParams Iterator {\n 'a',\n 'b',\n 'b' }"); 23assert.throws(() => sp[util.inspect.custom].call(), { 24 code: 'ERR_INVALID_THIS', 25}); 26 27const iterator = sp.entries(); 28assert.strictEqual(util.inspect(iterator), 29 "URLSearchParams Iterator { [ 'a', 'a' ], [ 'b', 'b' ], " + 30 "[ 'b', 'c' ] }"); 31iterator.next(); 32assert.strictEqual(util.inspect(iterator), 33 "URLSearchParams Iterator { [ 'b', 'b' ], [ 'b', 'c' ] }"); 34iterator.next(); 35iterator.next(); 36assert.strictEqual(util.inspect(iterator), 37 'URLSearchParams Iterator { }'); 38const emptySp = new URLSearchParams(); 39assert.strictEqual(util.inspect(emptySp), 'URLSearchParams {}'); 40