Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 62fd845

Browse filesBrowse files
BridgeARtargos
authored andcommitted
test: improve inspect readability
The string escaping is hard to read. This changes all those escaped strings to use double quotes instead so no escaping is necessary. PR-URL: #21624 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent f4b6031 commit 62fd845
Copy full SHA for 62fd845

File tree

Expand file treeCollapse file tree

1 file changed

+61
-61
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+61
-61
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-util-inspect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-util-inspect.js
+61-61Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ assert.strictEqual(
9393
Object.assign(new String('hello'), { [Symbol('foo')]: 123 }),
9494
{ showHidden: true }
9595
),
96-
'{ [String: \'hello\'] [length]: 5, [Symbol(foo)]: 123 }'
96+
"{ [String: 'hello'] [length]: 5, [Symbol(foo)]: 123 }"
9797
);
9898

9999
assert.strictEqual(util.inspect((new JSStream())._externalStream),
@@ -265,7 +265,7 @@ assert.strictEqual(
265265
name: { value: 'Tim', enumerable: true },
266266
hidden: { value: 'secret' }
267267
})),
268-
'{ name: \'Tim\' }'
268+
"{ name: 'Tim' }"
269269
);
270270

271271
// Dynamic properties.
@@ -308,7 +308,7 @@ assert.strictEqual(
308308
}
309309
);
310310
assert.strictEqual(util.inspect(value),
311-
'[ 1, 2, 3, growingLength: [Getter], \'-1\': -1 ]');
311+
"[ 1, 2, 3, growingLength: [Getter], '-1': -1 ]");
312312
}
313313

314314
// Array with inherited number properties.
@@ -422,24 +422,24 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
422422
// Test for sparse array.
423423
{
424424
const a = ['foo', 'bar', 'baz'];
425-
assert.strictEqual(util.inspect(a), '[ \'foo\', \'bar\', \'baz\' ]');
425+
assert.strictEqual(util.inspect(a), "[ 'foo', 'bar', 'baz' ]");
426426
delete a[1];
427-
assert.strictEqual(util.inspect(a), '[ \'foo\', <1 empty item>, \'baz\' ]');
427+
assert.strictEqual(util.inspect(a), "[ 'foo', <1 empty item>, 'baz' ]");
428428
assert.strictEqual(
429429
util.inspect(a, true),
430-
'[ \'foo\', <1 empty item>, \'baz\', [length]: 3 ]'
430+
"[ 'foo', <1 empty item>, 'baz', [length]: 3 ]"
431431
);
432432
assert.strictEqual(util.inspect(new Array(5)), '[ <5 empty items> ]');
433433
a[3] = 'bar';
434434
a[100] = 'qux';
435435
assert.strictEqual(
436436
util.inspect(a, { breakLength: Infinity }),
437-
'[ \'foo\', <1 empty item>, \'baz\', \'bar\', <96 empty items>, \'qux\' ]'
437+
"[ 'foo', <1 empty item>, 'baz', 'bar', <96 empty items>, 'qux' ]"
438438
);
439439
delete a[3];
440440
assert.strictEqual(
441441
util.inspect(a, { maxArrayLength: 4 }),
442-
'[ \'foo\', <1 empty item>, \'baz\', <97 empty items>, ... 1 more item ]'
442+
"[ 'foo', <1 empty item>, 'baz', <97 empty items>, ... 1 more item ]"
443443
);
444444
}
445445

@@ -630,13 +630,13 @@ util.inspect([{ inspect: () => 123 }]);
630630

631631
assert.strictEqual(
632632
util.inspect(w),
633-
'{ \'\\\\\': 1, \'\\\\\\\\\': 2, \'\\\\\\\\\\\\\': 3, ' +
634-
'\'\\\\\\\\\\\\\\\\\': 4, \'\\n\': 5, \'\\r\': 6 }'
633+
"{ '\\\\': 1, '\\\\\\\\': 2, '\\\\\\\\\\\\': 3, " +
634+
"'\\\\\\\\\\\\\\\\': 4, '\\n': 5, '\\r': 6 }"
635635
);
636636
assert.strictEqual(
637637
util.inspect(y),
638-
'[ \'a\', \'b\', \'c\', \'\\\\\\\\\': \'d\', ' +
639-
'\'\\n\': \'e\', \'\\r\': \'f\' ]'
638+
"[ 'a', 'b', 'c', '\\\\\\\\': 'd', " +
639+
"'\\n': 'e', '\\r': 'f' ]"
640640
);
641641
}
642642

@@ -758,7 +758,7 @@ util.inspect({ hasOwnProperty: null });
758758
// A custom [util.inspect.custom]() should be able to return other Objects.
759759
subject[util.inspect.custom] = () => ({ foo: 'bar' });
760760

761-
assert.strictEqual(util.inspect(subject), '{ foo: \'bar\' }');
761+
assert.strictEqual(util.inspect(subject), "{ foo: 'bar' }");
762762

763763
subject[util.inspect.custom] = (depth, opts) => {
764764
assert.strictEqual(opts.customInspectOptions, true);
@@ -828,7 +828,7 @@ util.inspect({ hasOwnProperty: null });
828828
}
829829

830830
// Test boxed primitives output the correct values.
831-
assert.strictEqual(util.inspect(new String('test')), '[String: \'test\']');
831+
assert.strictEqual(util.inspect(new String('test')), "[String: 'test']");
832832
assert.strictEqual(
833833
util.inspect(Object(Symbol('test'))),
834834
'[Symbol: Symbol(test)]'
@@ -844,15 +844,15 @@ assert.strictEqual(util.inspect(new Number(13.37)), '[Number: 13.37]');
844844
{
845845
const str = new String('baz');
846846
str.foo = 'bar';
847-
assert.strictEqual(util.inspect(str), '{ [String: \'baz\'] foo: \'bar\' }');
847+
assert.strictEqual(util.inspect(str), "{ [String: 'baz'] foo: 'bar' }");
848848

849849
const bool = new Boolean(true);
850850
bool.foo = 'bar';
851-
assert.strictEqual(util.inspect(bool), '{ [Boolean: true] foo: \'bar\' }');
851+
assert.strictEqual(util.inspect(bool), "{ [Boolean: true] foo: 'bar' }");
852852

853853
const num = new Number(13.37);
854854
num.foo = 'bar';
855-
assert.strictEqual(util.inspect(num), '{ [Number: 13.37] foo: \'bar\' }');
855+
assert.strictEqual(util.inspect(num), "{ [Number: 13.37] foo: 'bar' }");
856856
}
857857

858858
// Test es6 Symbol.
@@ -881,7 +881,7 @@ if (typeof Symbol !== 'undefined') {
881881
assert.strictEqual(util.inspect(subject), '{ [Symbol(symbol)]: 42 }');
882882
assert.strictEqual(
883883
util.inspect(subject, options),
884-
'{ [Symbol(symbol)]: 42, [Symbol()]: \'non-enum\' }'
884+
"{ [Symbol(symbol)]: 42, [Symbol()]: 'non-enum' }"
885885
);
886886

887887
subject = [1, 2, 3];
@@ -899,7 +899,7 @@ if (typeof Symbol !== 'undefined') {
899899
set.bar = 42;
900900
assert.strictEqual(
901901
util.inspect(set, true),
902-
'Set { \'foo\', [size]: 1, bar: 42 }'
902+
"Set { 'foo', [size]: 1, bar: 42 }"
903903
);
904904
}
905905

@@ -914,11 +914,11 @@ if (typeof Symbol !== 'undefined') {
914914
{
915915
assert.strictEqual(util.inspect(new Map()), 'Map {}');
916916
assert.strictEqual(util.inspect(new Map([[1, 'a'], [2, 'b'], [3, 'c']])),
917-
'Map { 1 => \'a\', 2 => \'b\', 3 => \'c\' }');
917+
"Map { 1 => 'a', 2 => 'b', 3 => 'c' }");
918918
const map = new Map([['foo', null]]);
919919
map.bar = 42;
920920
assert.strictEqual(util.inspect(map, true),
921-
'Map { \'foo\' => null, [size]: 1, bar: 42 }');
921+
"Map { 'foo' => null, [size]: 1, bar: 42 }");
922922
}
923923

924924
// Test circular Map.
@@ -949,7 +949,7 @@ if (typeof Symbol !== 'undefined') {
949949
const promiseWithProperty = Promise.resolve('foo');
950950
promiseWithProperty.bar = 42;
951951
assert.strictEqual(util.inspect(promiseWithProperty),
952-
'Promise { \'foo\', bar: 42 }');
952+
"Promise { 'foo', bar: 42 }");
953953
}
954954

955955
// Make sure it doesn't choke on polyfills. Unlike Set/Map, there is no standard
@@ -965,14 +965,14 @@ if (typeof Symbol !== 'undefined') {
965965
// Test Map iterators.
966966
{
967967
const map = new Map([['foo', 'bar']]);
968-
assert.strictEqual(util.inspect(map.keys()), '[Map Iterator] { \'foo\' }');
969-
assert.strictEqual(util.inspect(map.values()), '[Map Iterator] { \'bar\' }');
968+
assert.strictEqual(util.inspect(map.keys()), "[Map Iterator] { 'foo' }");
969+
assert.strictEqual(util.inspect(map.values()), "[Map Iterator] { 'bar' }");
970970
assert.strictEqual(util.inspect(map.entries()),
971-
'[Map Iterator] { [ \'foo\', \'bar\' ] }');
971+
"[Map Iterator] { [ 'foo', 'bar' ] }");
972972
// Make sure the iterator doesn't get consumed.
973973
const keys = map.keys();
974-
assert.strictEqual(util.inspect(keys), '[Map Iterator] { \'foo\' }');
975-
assert.strictEqual(util.inspect(keys), '[Map Iterator] { \'foo\' }');
974+
assert.strictEqual(util.inspect(keys), "[Map Iterator] { 'foo' }");
975+
assert.strictEqual(util.inspect(keys), "[Map Iterator] { 'foo' }");
976976
keys.extra = true;
977977
assert.strictEqual(
978978
util.inspect(keys, { maxArrayLength: 0 }),
@@ -1047,7 +1047,7 @@ if (typeof Symbol !== 'undefined') {
10471047
assert.strictEqual(util.inspect(new SetSubclass([1, 2, 3])),
10481048
'SetSubclass [Set] { 1, 2, 3 }');
10491049
assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])),
1050-
'MapSubclass [Map] { \'foo\' => 42 }');
1050+
"MapSubclass [Map] { 'foo' => 42 }");
10511051
assert.strictEqual(util.inspect(new PromiseSubclass(() => {})),
10521052
'PromiseSubclass [Promise] { <pending> }');
10531053
assert.strictEqual(
@@ -1100,7 +1100,7 @@ if (typeof Symbol !== 'undefined') {
11001100
{
11011101
const x = [];
11021102
x[''] = 1;
1103-
assert.strictEqual(util.inspect(x), '[ \'\': 1 ]');
1103+
assert.strictEqual(util.inspect(x), "[ '': 1 ]");
11041104
}
11051105

11061106
// The following maxArrayLength tests were introduced after v6.0.0 was released.
@@ -1146,10 +1146,10 @@ if (typeof Symbol !== 'undefined') {
11461146
const breakpoint = oneLine.length - 5;
11471147
const twoLines = util.inspect(obj, { breakLength: breakpoint });
11481148

1149-
assert.strictEqual(oneLine, '{ foo: \'abc\', bar: \'xyz\' }');
1149+
assert.strictEqual(oneLine, "{ foo: 'abc', bar: 'xyz' }");
11501150
assert.strictEqual(oneLine,
11511151
util.inspect(obj, { breakLength: breakpoint + 1 }));
1152-
assert.strictEqual(twoLines, '{ foo: \'abc\',\n bar: \'xyz\' }');
1152+
assert.strictEqual(twoLines, "{ foo: 'abc',\n bar: 'xyz' }");
11531153
}
11541154

11551155
// util.inspect.defaultOptions tests.
@@ -1217,7 +1217,7 @@ util.inspect(process);
12171217
{
12181218
// @@toStringTag
12191219
assert.strictEqual(util.inspect({ [Symbol.toStringTag]: 'a' }),
1220-
'Object [a] { [Symbol(Symbol.toStringTag)]: \'a\' }');
1220+
"Object [a] { [Symbol(Symbol.toStringTag)]: 'a' }");
12211221

12221222
class Foo {
12231223
constructor() {
@@ -1233,17 +1233,17 @@ util.inspect(process);
12331233
Object.create(null, { [Symbol.toStringTag]: { value: 'foo' } })),
12341234
'[foo] {}');
12351235

1236-
assert.strictEqual(util.inspect(new Foo()), 'Foo [bar] { foo: \'bar\' }');
1236+
assert.strictEqual(util.inspect(new Foo()), "Foo [bar] { foo: 'bar' }");
12371237

12381238
assert.strictEqual(
12391239
util.inspect(new (class extends Foo {})()),
1240-
'Foo [bar] { foo: \'bar\' }');
1240+
"Foo [bar] { foo: 'bar' }");
12411241

12421242
assert.strictEqual(
12431243
util.inspect(Object.create(Object.create(Foo.prototype), {
12441244
foo: { value: 'bar', enumerable: true }
12451245
})),
1246-
'Foo [bar] { foo: \'bar\' }');
1246+
"Foo [bar] { foo: 'bar' }");
12471247

12481248
class ThrowingClass {
12491249
get [Symbol.toStringTag]() {
@@ -1295,69 +1295,69 @@ util.inspect(process);
12951295
' 2,',
12961296
' [',
12971297
' [',
1298-
' \'Lorem ipsum dolor\\nsit amet,\\tconsectetur \' +',
1299-
' \'adipiscing elit, sed do eiusmod tempor \' +',
1300-
' \'incididunt ut labore et dolore magna \' +',
1301-
' \'aliqua.\',',
1302-
' \'test\',',
1303-
' \'foo\'',
1298+
" 'Lorem ipsum dolor\\nsit amet,\\tconsectetur ' +",
1299+
" 'adipiscing elit, sed do eiusmod tempor ' +",
1300+
" 'incididunt ut labore et dolore magna ' +",
1301+
" 'aliqua.',",
1302+
" 'test',",
1303+
" 'foo'",
13041304
' ]',
13051305
' ],',
13061306
' 4',
13071307
' ],',
13081308
' b: Map {',
1309-
' \'za\' => 1,',
1310-
' \'zb\' => \'test\'',
1309+
" 'za' => 1,",
1310+
" 'zb' => 'test'",
13111311
' }',
13121312
'}'
13131313
].join('\n');
13141314
assert.strictEqual(out, expect);
13151315

13161316
out = util.inspect(o.a[2][0][0], { compact: false, breakLength: 30 });
13171317
expect = [
1318-
'\'Lorem ipsum dolor\\nsit \' +',
1319-
' \'amet,\\tconsectetur \' +',
1320-
' \'adipiscing elit, sed do \' +',
1321-
' \'eiusmod tempor incididunt \' +',
1322-
' \'ut labore et dolore magna \' +',
1323-
' \'aliqua.\''
1318+
"'Lorem ipsum dolor\\nsit ' +",
1319+
" 'amet,\\tconsectetur ' +",
1320+
" 'adipiscing elit, sed do ' +",
1321+
" 'eiusmod tempor incididunt ' +",
1322+
" 'ut labore et dolore magna ' +",
1323+
" 'aliqua.'"
13241324
].join('\n');
13251325
assert.strictEqual(out, expect);
13261326

13271327
out = util.inspect(
13281328
'12345678901234567890123456789012345678901234567890',
13291329
{ compact: false, breakLength: 3 });
1330-
expect = '\'12345678901234567890123456789012345678901234567890\'';
1330+
expect = "'12345678901234567890123456789012345678901234567890'";
13311331
assert.strictEqual(out, expect);
13321332

13331333
out = util.inspect(
13341334
'12 45 78 01 34 67 90 23 56 89 123456789012345678901234567890',
13351335
{ compact: false, breakLength: 3 });
13361336
expect = [
1337-
'\'12 45 78 01 34 \' +',
1338-
' \'67 90 23 56 89 \' +',
1339-
' \'123456789012345678901234567890\''
1337+
"'12 45 78 01 34 ' +",
1338+
" '67 90 23 56 89 ' +",
1339+
" '123456789012345678901234567890'"
13401340
].join('\n');
13411341
assert.strictEqual(out, expect);
13421342

13431343
out = util.inspect(
13441344
'12 45 78 01 34 67 90 23 56 89 1234567890123 0',
13451345
{ compact: false, breakLength: 3 });
13461346
expect = [
1347-
'\'12 45 78 01 34 \' +',
1348-
' \'67 90 23 56 89 \' +',
1349-
' \'1234567890123 0\''
1347+
"'12 45 78 01 34 ' +",
1348+
" '67 90 23 56 89 ' +",
1349+
" '1234567890123 0'"
13501350
].join('\n');
13511351
assert.strictEqual(out, expect);
13521352

13531353
out = util.inspect(
13541354
'12 45 78 01 34 67 90 23 56 89 12345678901234567 0',
13551355
{ compact: false, breakLength: 3 });
13561356
expect = [
1357-
'\'12 45 78 01 34 \' +',
1358-
' \'67 90 23 56 89 \' +',
1359-
' \'12345678901234567 \' +',
1360-
' \'0\''
1357+
"'12 45 78 01 34 ' +",
1358+
" '67 90 23 56 89 ' +",
1359+
" '12345678901234567 ' +",
1360+
" '0'"
13611361
].join('\n');
13621362
assert.strictEqual(out, expect);
13631363

@@ -1396,7 +1396,7 @@ util.inspect(process);
13961396

13971397
o[util.inspect.custom] = () => ({ a: '12 45 78 01 34 67 90 23' });
13981398
out = util.inspect(o, { compact: false, breakLength: 3 });
1399-
expect = '{\n a: \'12 45 78 01 34 \' +\n \'67 90 23\'\n}';
1399+
expect = "{\n a: '12 45 78 01 34 ' +\n '67 90 23'\n}";
14001400
assert.strictEqual(out, expect);
14011401
}
14021402

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.