'use strict';
const common = require('../common');
const assert = require('assert');
const util = require('util');
const { inspect } = util;
assert.strictEqual(util.inspect(1), '1');
assert.strictEqual(util.inspect(false), 'false');
assert.strictEqual(util.inspect(''), "''");
assert.strictEqual(util.inspect('hello'), "'hello'");
assert.strictEqual(util.inspect(function abc() {}), '[Function: abc]');
assert.strictEqual(util.inspect(() => {}), '[Function (anonymous)]');
assert.strictEqual(
util.inspect(async function() {}),
'[AsyncFunction (anonymous)]'
);
assert.strictEqual(util.inspect(async () => {}), '[AsyncFunction (anonymous)]');
{
const fn = (() => function*() {})();
assert.strictEqual(
util.inspect(fn),
'[GeneratorFunction (anonymous)]'
);
Object.setPrototypeOf(fn, Object.getPrototypeOf(async () => {}));
Object.defineProperty(fn, 'name', { value: 5, configurable: true });
Object.defineProperty(fn, Symbol.toStringTag, {
value: 'Foobar',
configurable: true
});
Object.defineProperty(fn, 'name', { value: '5', configurable: true });
Object.setPrototypeOf(fn, null);
}
assert.strictEqual(util.inspect(undefined), 'undefined');
assert.strictEqual(util.inspect(null), 'null');
assert.strictEqual(util.inspect(/foo(bar\n)?/gi), '/foo(bar\\n)?/gi');
assert.strictEqual(
util.inspect(new Date('Sun, 14 Feb 2010 11:48:40 GMT')),
new Date('2010-02-14T12:48:40+01:00').toISOString()
);
assert.strictEqual(util.inspect(new Date('')), (new Date('')).toString());
assert.strictEqual(util.inspect('\n\x01'), "'\\n\\x01'");
assert.strictEqual(
util.inspect(`${Array(75).fill(1)}'\n\x1d\n\x03\x85\x7f\x7e\x9f\xa0`),
`"${Array(75).fill(1)}'\\n" +\n '\\x1D\\n' +\n '\\x03\\x85\\x7F~\\x9F '`
);
assert.strictEqual(util.inspect([]), '[]');
assert.strictEqual(util.inspect(Object.create([])), 'Array {}');
assert.strictEqual(util.inspect([1, 2]), '[ 1, 2 ]');
assert.strictEqual(util.inspect([1, [2, 3]]), '[ 1, [ 2, 3 ] ]');
assert.strictEqual(util.inspect({}), '{}');
assert.strictEqual(util.inspect({ a: 1 }), '{ a: 1 }');
assert.strictEqual(util.inspect({ a: function() {} }), '{ a: [Function: a] }');
assert.strictEqual(util.inspect({ a: () => {} }), '{ a: [Function: a] }');
assert.strictEqual(util.inspect({ a: async function abc() {} }),
'{ a: [AsyncFunction: abc] }');
assert.strictEqual(util.inspect({ a: async () => {} }),
'{ a: [AsyncFunction: a] }');
assert.strictEqual(util.inspect({ a: function*() {} }),
'{ a: [GeneratorFunction: a] }');
assert.strictEqual(util.inspect({ a: 1, b: 2 }), '{ a: 1, b: 2 }');
assert.strictEqual(util.inspect({ 'a': {} }), '{ a: {} }');
assert.strictEqual(util.inspect({ 'a': { 'b': 2 } }), '{ a: { b: 2 } }');
assert.strictEqual(util.inspect({ 'a': { 'b': { 'c': { 'd': 2 } } } }),
'{ a: { b: { c: [Object] } } }');
assert.strictEqual(
util.inspect({ 'a': { 'b': { 'c': { 'd': 2 } } } }, false, null),
'{\n a: { b: { c: { d: 2 } } }\n}');
assert.strictEqual(util.inspect({ 'a': { 'b': { 'c': 2 } } }, false, 0),
'{ a: [Object] }');
assert.strictEqual(util.inspect({ 'a': { 'b': { 'c': 2 } } }, false, 1),
'{ a: { b: [Object] } }');
assert.strictEqual(util.inspect({ 'a': { 'b': ['c'] } }, false, 1),
'{ a: { b: [Array] } }');
assert.strictEqual(
util.inspect(
Object.create(
{},
{ visible: { value: 1, enumerable: true }, hidden: { value: 2 } }
)
),
'{ visible: 1 }'
);
{
const regexp = /regexp/;
regexp.aprop = 42;
assert.strictEqual(util.inspect({ a: regexp }, false, 0), '{ a: /regexp/ }');
}
assert.match(
util.inspect({ a: { a: { a: { a: {} } } } }, undefined, undefined, true),
/Object/
);
assert.doesNotMatch(
util.inspect({ a: { a: { a: { a: {} } } } }, undefined, null, true),
/Object/
);
assert.strictEqual(
util.inspect(Object.create({}, {
visible: { value: 1, enumerable: true },
hidden: { value: 2 }
}), { showHidden: true }),
'{ visible: 1, [hidden]: 2 }'
);
assert.strictEqual(
util.inspect(Object.create(null, {
name: { value: 'Tim', enumerable: true },
hidden: { value: 'secret' }
}), { showHidden: true }),
"[Object: null prototype] { name: 'Tim', [hidden]: 'secret' }"
);
assert.strictEqual(
util.inspect(Object.create(null, {
name: { value: 'Tim', enumerable: true },
hidden: { value: 'secret' }
})),
"[Object: null prototype] { name: 'Tim' }"
);
{
assert.strictEqual(
util.inspect({ get readonly() { return 1; } }),
'{ readonly: [Getter] }');
assert.strictEqual(
util.inspect({ get readwrite() { return 1; }, set readwrite(val) {} }),
'{ readwrite: [Getter/Setter] }');
assert.strictEqual(
util.inspect({ set writeonly(val) {} }),
'{ writeonly: [Setter] }');
const value = {};
value.a = value;
assert.strictEqual(util.inspect(value), '<ref *1> { a: [Circular *1] }');
const getterFn = {
get one() {
return null;
}
};
assert.strictEqual(
util.inspect(getterFn, { getters: true }),
'{ one: [Getter: null] }'
);
}
{
class CustomArray extends Array {}
CustomArray.prototype[5] = 'foo';
CustomArray.prototype[49] = 'bar';
CustomArray.prototype.foo = true;
const arr = new CustomArray(50);
arr[49] = 'I win';
assert.strictEqual(
util.inspect(arr),
"CustomArray(50) [ <49 empty items>, 'I win' ]"
);
}
{
const value = () => {};
value.aprop = 42;
assert.strictEqual(util.inspect(value), '[Function: value] { aprop: 42 }');
}
{
const value = (() => function() {})();
value.aprop = 42;
assert.strictEqual(
util.inspect(value),
'[Function (anonymous)] { aprop: 42 }'
);
}
{
const value = /123/ig;
value.aprop = 42;
assert.strictEqual(util.inspect(value), '/123/gi { aprop: 42 }');
}
{
const value = new Date('Sun, 14 Feb 2010 11:48:40 GMT');
value.aprop = 42;
assert.strictEqual(util.inspect(value),
'2010-02-14T11:48:40.000Z { aprop: 42 }');
}
assert.strictEqual(util.inspect(0), '0');
assert.strictEqual(util.inspect(-0), '-0');
assert.strictEqual(util.inspect(-5e-324), '-5e-324');
{
const a = ['foo', 'bar', 'baz'];
assert.strictEqual(util.inspect(a), "[ 'foo', 'bar', 'baz' ]");
delete a[1];
assert.strictEqual(util.inspect(a), "[ 'foo', <1 empty item>, 'baz' ]");
assert.strictEqual(util.inspect(new Array(5)), '[ <5 empty items> ]');
a[3] = 'bar';
a[100] = 'qux';
assert.strictEqual(
util.inspect(a, { breakLength: Infinity }),
"[ 'foo', <1 empty item>, 'baz', 'bar', <96 empty items>, 'qux' ]"
);
delete a[3];
assert.strictEqual(
util.inspect(a, { maxArrayLength: 4 }),
"[ 'foo', <1 empty item>, 'baz', <97 empty items>, ... 1 more item ]"
);
assert.strictEqual(util.inspect(a, {
maxArrayLength: 2
}), "[ 'foo', <1 empty item>, ... 99 more items ]");
}
{
const getter = Object.create(null, {
a: {
get: function() { return 'aaa'; }
}
});
const setter = Object.create(null, {
b: { set: function() {}
}
});
const getterAndSetter = Object.create(null, {
c: {
get: function() { return 'ccc'; },
set: function() {}
}
});
assert.strictEqual(
util.inspect(getter, true),
'[Object: null prototype] { [a]: [Getter] }'
);
assert.strictEqual(
util.inspect(setter, true),
'[Object: null prototype] { [b]: [Setter] }'
);
assert.strictEqual(
util.inspect(getterAndSetter, true),
'[Object: null prototype] { [c]: [Getter/Setter] }'
);
}
{
[
new Error(),
new Error('FAIL'),
new TypeError('FAIL'),
new SyntaxError('FAIL'),
].forEach((err) => {
assert.strictEqual(util.inspect(err), err.stack);
});
assert.throws(
() => undef(), (e) => {
assert.strictEqual(util.inspect(e), e.stack);
return true;
}
);
const ex = util.inspect(new Error('FAIL'), true);
assert(ex.includes('Error: FAIL'));
assert(ex.includes('[stack]'));
assert(ex.includes('[message]'));
}
{
const tmp = Error.stackTraceLimit;
Error.stackTraceLimit = 0;
const err = new Error('foo');
const err2 = new Error('foo\nbar');
assert.strictEqual(util.inspect(err, { compact: true }), '[Error: foo]');
assert(err.stack);
delete err.stack;
assert(!err.stack);
}
{
function BadCustomError(msg) {
Error.call(this);
Object.defineProperty(this, 'message',
{ value: msg, enumerable: false });
Object.defineProperty(this, 'name',
{ value: 'BadCustomError', enumerable: false });
}
Object.setPrototypeOf(BadCustomError.prototype, Error.prototype);
Object.setPrototypeOf(BadCustomError, Error);
assert.strictEqual(
util.inspect(new BadCustomError('foo')),
'[BadCustomError: foo]'
);
}
assert.strictEqual(util.inspect(Object.create(Date.prototype)), 'Date {}');
{
const d = new Date();
d.toUTCString = null;
util.inspect(d);
}
{
function testColorStyle(style, input, implicit) {
const colorName = util.inspect.styles[style];
let color = ['', ''];
if (util.inspect.colors[colorName])
color = util.inspect.colors[colorName];
const withoutColor = util.inspect(input, false, 0, false);
const withColor = util.inspect(input, false, 0, true);
const expect = `\u001b[${color[0]}m${withoutColor}\u001b[${color[1]}m`;
assert.strictEqual(
withColor,
expect,
`util.inspect color for style ${style}`);
}
testColorStyle('special', function() {});
testColorStyle('number', 123.456);
testColorStyle('boolean', true);
testColorStyle('undefined', undefined);
testColorStyle('null', null);
testColorStyle('string', 'test string');
testColorStyle('date', new Date());
testColorStyle('regexp', /regexp/);
}
util.inspect({ hasOwnProperty: null });
{
const subject = { foo: 'bar', hello: 31, a: { b: { c: { d: 0 } } } };
Object.defineProperty(subject, 'hidden', { enumerable: false, value: null });
assert.strictEqual(
util.inspect(subject, { showHidden: false }).includes('hidden'),
false
);
assert.strictEqual(
util.inspect(subject, { showHidden: true }).includes('hidden'),
true
);
assert.strictEqual(
util.inspect(subject, { colors: false }).includes('\u001b[32m'),
false
);
assert.strictEqual(
util.inspect(subject, { colors: true }).includes('\u001b[32m'),
true
);
assert.strictEqual(
util.inspect(subject, { depth: 2 }).includes('c: [Object]'),
true
);
assert.strictEqual(
util.inspect(subject, { depth: 0 }).includes('a: [Object]'),
true
);
assert.strictEqual(
util.inspect(subject, { depth: null }).includes('{ d: 0 }'),
true
);
assert.strictEqual(
util.inspect(subject, { depth: undefined }).includes('{ d: 0 }'),
true
);
}
{
const subject = { [util.inspect.custom]: () => 123 };
assert.strictEqual(
util.inspect(subject, { customInspect: true }).includes('123'),
true
);
assert.strictEqual(
util.inspect(subject, { customInspect: true }).includes('inspect'),
false
);
assert.strictEqual(
util.inspect(subject, { customInspect: false }).includes('123'),
false
);
subject[util.inspect.custom] = () => ({ foo: 'bar' });
assert.strictEqual(util.inspect(subject), "{ foo: 'bar' }");
subject[util.inspect.custom] = common.mustCall((depth, opts) => {
const clone = { ...opts };
assert.strictEqual(typeof opts.stylize, 'function');
assert.strictEqual(opts.seen, undefined);
assert.strictEqual(opts.budget, undefined);
assert.strictEqual(opts.indentationLvl, undefined);
assert.strictEqual(opts.showHidden, false);
assert.deepStrictEqual(
new Set(Object.keys(util.inspect.defaultOptions).concat(['stylize'])),
new Set(Object.keys(opts))
);
opts.showHidden = true;
return { [util.inspect.custom]: common.mustCall((depth, opts2) => {
assert.deepStrictEqual(clone, opts2);
}) };
});
util.inspect(subject);
const inspect = Symbol.for('nodejs.util.inspect.custom');
subject[inspect] = () => ({ baz: 'quux' });
assert.strictEqual(util.inspect(subject), '{ baz: \'quux\' }');
subject[inspect] = (depth, opts) => {
assert.strictEqual(opts.customInspectOptions, true);
assert.strictEqual(opts.seen, null);
return {};
};
util.inspect(subject, { customInspectOptions: true, seen: null });
}
{
const subject = { [util.inspect.custom]: common.mustCall((depth, opts) => {
assert.strictEqual(depth, null);
assert.strictEqual(opts.compact, true);
}) };
util.inspect(subject, { depth: null, compact: true });
}
assert.strictEqual(
util.inspect([1, 2, 3], { stylize() { return 'x'; } }),
'[ x, x, x ]'
);
{
function testLines(input) {
const countLines = (str) => (str.match(/\n/g) || []).length;
const withoutColor = util.inspect(input);
const withColor = util.inspect(input, { colors: true });
assert.strictEqual(countLines(withoutColor), countLines(withColor));
}
const bigArray = new Array(100).fill().map((value, index) => index);
testLines([1, 2, 3, 4, 5, 6, 7]);
testLines(bigArray);
testLines({ foo: 'bar', baz: 35, b: { a: 35 } });
testLines({ a: { a: 3, b: 1, c: 1, d: 1, e: 1, f: 1, g: 1, h: 1 }, b: 1 });
testLines({
foo: 'bar',
baz: 35,
b: { a: 35 },
veryLongKey: 'very long value',
evenLongerKey: ['with even longer value in array']
});
}
assert.strictEqual(util.inspect(new String('test')), "[String: 'test']");
assert.strictEqual(
util.inspect(new String('test'), { colors: true }),
"\u001b[32m[String: 'test']\u001b[39m"
);
assert.strictEqual(
util.inspect(Object(Symbol('test'))),
'[Symbol: Symbol(test)]'
);
assert.strictEqual(util.inspect(new Boolean(false)), '[Boolean: false]');
assert.strictEqual(util.inspect(new Number(-1.1)), '[Number: -1.1]');
assert.strictEqual(util.inspect(new Number(13.37)), '[Number: 13.37]');
{
const str = new String('baz');
str.foo = 'bar';
assert.strictEqual(util.inspect(str), "[String: 'baz'] { foo: 'bar' }");
const bool = new Boolean(true);
bool.foo = 'bar';
assert.strictEqual(util.inspect(bool), "[Boolean: true] { foo: 'bar' }");
const num = new Number(13.37);
num.foo = 'bar';
assert.strictEqual(util.inspect(num), "[Number: 13.37] { foo: 'bar' }");
const sym = Object(Symbol('foo'));
sym.foo = 'bar';
assert.strictEqual(util.inspect(sym), "[Symbol: Symbol(foo)] { foo: 'bar' }");
const big = Object(BigInt(55));
big.foo = 'bar';
assert.strictEqual(util.inspect(big), "[BigInt: 55n] { foo: 'bar' }");
}
if (typeof Symbol !== 'undefined') {
assert.strictEqual(util.inspect(Symbol()), 'Symbol()');
assert.strictEqual(util.inspect(Symbol(123)), 'Symbol(123)');
assert.strictEqual(util.inspect(Symbol('hi')), 'Symbol(hi)');
assert.strictEqual(util.inspect([Symbol()]), '[ Symbol() ]');
assert.strictEqual(util.inspect({ foo: Symbol() }), '{ foo: Symbol() }');
const options = { showHidden: true };
let subject = {};
subject[Symbol('sym\nbol')] = 42;
}
{
assert.strictEqual(util.inspect(new Set()), 'Set(0) {}');
}
{
assert.strictEqual(util.inspect(new Map()), 'Map(0) {}');
assert.strictEqual(util.inspect(new Map([[1, 'a'], [2, 'b'], [3, 'c']])),
"Map(3) { 1 => 'a', 2 => 'b', 3 => 'c' }");
const map = new Map([['foo', null]]);
map.bar = 42;
assert.strictEqual(util.inspect(map, true),
"Map(1) { 'foo' => null, bar: 42 }");
}
{
const map = new Map();
map.set(map, 'map');
assert.strictEqual(
inspect(map),
"<ref *1> Map(1) { [Circular *1] => 'map' }"
);
map.set(map, map);
assert.strictEqual(
inspect(map),
'<ref *1> Map(1) { [Circular *1] => [Circular *1] }'
);
map.delete(map);
map.set('map', map);
assert.strictEqual(
inspect(map),
"<ref *1> Map(1) { 'map' => [Circular *1] }"
);
}
{
const obj = {};
obj.a = [obj];
obj.b = {};
obj.b.inner = obj.b;
obj.b.obj = obj;
assert.strictEqual(
inspect(obj),
'<ref *1> {\n' +
' a: [ [Circular *1] ],\n' +
' b: <ref *2> { inner: [Circular *2], obj: [Circular *1] }\n' +
'}'
);
}
{
const oldPromise = Promise;
global.Promise = function() { this.bar = 42; };
assert.strictEqual(util.inspect(new Promise()), '{ bar: 42 }');
global.Promise = oldPromise;
}
{
class Foo {
get [Symbol.toStringTag]() {
return 'ABC';
}
}
const a = new Foo();
assert.strictEqual(inspect(a, { depth: -1 }), 'Foo [ABC] {}');
a.foo = true;
assert.strictEqual(inspect(a, { depth: -1 }), '[Foo [ABC]]');
Object.defineProperty(a, Symbol.toStringTag, {
value: 'Foo',
configurable: true,
writable: true
});
assert.strictEqual(inspect(a, { depth: -1 }), '[Foo]');
delete a[Symbol.toStringTag];
Object.setPrototypeOf(a, null);
}
{
function checkAlignment(container, start, lineX, end) {
const lines = util.inspect(container).split('\n');
lines.forEach((line, i) => {
if (i === 0) {
assert.strictEqual(line, start);
} else if (i === lines.length - 1) {
assert.strictEqual(line, end);
} else {
let expected = lineX.replace('X', i - 1);
if (i !== lines.length - 2)
expected += ',';
assert.strictEqual(line, expected);
}
});
}
const bigArray = [];
for (let i = 0; i < 100; i++) {
bigArray.push(i);
}
const obj = {};
bigArray.forEach((prop) => {
obj[prop] = null;
});
checkAlignment(obj, '{', " 'X': null", '}');
checkAlignment(
new Map(bigArray.map((number) => [number, null])),
'Map(100) {', ' X => null', '}'
);
}
{
class ObjectSubclass {}
class ArraySubclass extends Array {}
class SetSubclass extends Set {}
class MapSubclass extends Map {}
class PromiseSubclass extends Promise {}
const x = new ObjectSubclass();
x.foo = 42;
assert.strictEqual(util.inspect(x),
'ObjectSubclass { foo: 42 }');
assert.strictEqual(util.inspect(new ArraySubclass(1, 2, 3)),
'ArraySubclass(3) [ 1, 2, 3 ]');
assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])),
"MapSubclass(1) [Map] { 'foo' => 42 }");
assert.strictEqual(
util.inspect({ a: { b: new ArraySubclass([1, [2], 3]) } }, { depth: 1 }),
'{ a: { b: [ArraySubclass] } }'
);
}
{
const arr = [[[[]]]];
assert.strictEqual(util.inspect(arr), '[ [ [ [] ] ] ]');
arr[0][0][0][0] = [];
assert.strictEqual(util.inspect(arr), '[ [ [ [Array] ] ] ]');
arr[0][0][0] = {};
assert.strictEqual(util.inspect(arr), '[ [ [ {} ] ] ]');
arr[0][0][0] = { a: 2 };
assert.strictEqual(util.inspect(arr), '[ [ [ [Object] ] ] ]');
arr[0][0][0] = arr;
assert.strictEqual(util.inspect(arr), '<ref *1> [ [ [ [Circular *1] ] ] ]');
arr[0][0][0] = arr[0][0];
assert.strictEqual(util.inspect(arr), '[ [ <ref *1> [ [Circular *1] ] ] ]');
}
{
const x = { constructor: 42 };
assert.strictEqual(util.inspect(x), '{ constructor: 42 }');
}
{
const x = {};
Object.defineProperty(x, 'constructor', {
get: function() {
throw new Error('should not access constructor');
},
enumerable: true
});
assert.strictEqual(util.inspect(x), '{ constructor: [Getter] }');
}
{
const x = new function() {}; assert.strictEqual(util.inspect(x), '{}');
}
{
const x = Object.create(null);
assert.strictEqual(util.inspect(x), '[Object: null prototype] {}');
}
{
const x = Array(101);
assert.strictEqual(util.inspect(x, { maxArrayLength: 0 }),
'[ ... 101 more items ]');
assert(!util.inspect(x, { maxArrayLength: null }).endsWith('1 more item\n]'));
assert(!util.inspect(
x, { maxArrayLength: Infinity }
).endsWith('1 more item ]'));
}
{
const x = new Uint8Array(101);
assert(!util.inspect(x, { maxArrayLength: 101 }).includes('1 more item'));
assert(!util.inspect(x, { maxArrayLength: null }).includes('1 more item'));
}
{
const obj = { foo: 'abc', bar: 'xyz' };
const oneLine = util.inspect(obj, { breakLength: Infinity });
const breakpoint = oneLine.length - 5;
const twoLines = util.inspect(obj, { breakLength: breakpoint });
assert.strictEqual(oneLine, "{ foo: 'abc', bar: 'xyz' }");
assert.strictEqual(
util.inspect(obj, { breakLength: breakpoint + 1 }),
twoLines
);
assert.strictEqual(twoLines, "{\n foo: 'abc',\n bar: 'xyz'\n}");
}
{
const arr = new Array(101).fill();
const obj = { a: { a: { a: { a: 1 } } } };
const oldOptions = { ...util.inspect.defaultOptions };
util.inspect.defaultOptions.maxArrayLength = null;
assert.doesNotMatch(util.inspect(arr), /1 more item/);
util.inspect.defaultOptions.maxArrayLength = oldOptions.maxArrayLength;
util.inspect.defaultOptions.depth = null;
assert.doesNotMatch(util.inspect(obj), /Object/);
util.inspect.defaultOptions.depth = oldOptions.depth;
assert.match(util.inspect(obj), /Object/);
assert.strictEqual(
JSON.stringify(util.inspect.defaultOptions),
JSON.stringify(oldOptions)
);
util.inspect.defaultOptions = { maxArrayLength: null, depth: 2 };
assert.doesNotMatch(util.inspect(arr), /1 more item/);
assert.match(util.inspect(obj), /Object/);
util.inspect.defaultOptions = oldOptions;
assert.match(util.inspect(obj), /Object/);
assert.strictEqual(
JSON.stringify(util.inspect.defaultOptions),
JSON.stringify(oldOptions)
);
assert.throws(() => {
util.inspect.defaultOptions = null;
}, {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message: 'The "options" argument must be of type object. ' +
'Received null'
}
);
assert.throws(() => {
util.inspect.defaultOptions = 'bad';
}, {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message: 'The "options" argument must be of type object. ' +
"Received type string ('bad')"
}
);
}
util.inspect(process);
{
const obj = { [Symbol.toStringTag]: 'a' };
Object.defineProperty(obj, Symbol.toStringTag, {
value: 'a',
enumerable: false
});
assert.strictEqual(util.inspect(obj), 'Object [a] {}');
class Foo {
constructor() {
this.foo = 'bar';
}
get [Symbol.toStringTag]() {
return this.foo;
}
}
assert.strictEqual(util.inspect(new Foo()), "Foo [bar] { foo: 'bar' }");
assert.strictEqual(
util.inspect(new (class extends Foo {})()),
"Foo [bar] { foo: 'bar' }");
assert.strictEqual(
util.inspect(Object.create(Object.create(Foo.prototype), {
foo: { value: 'bar', enumerable: true }
})),
"Foo [bar] { foo: 'bar' }");
class ThrowingClass {
get [Symbol.toStringTag]() {
throw new Error('toStringTag error');
}
}
assert.throws(() => util.inspect(new ThrowingClass()), /toStringTag error/);
class NotStringClass {
get [Symbol.toStringTag]() {
return null;
}
}
assert.strictEqual(util.inspect(new NotStringClass()),
'NotStringClass {}');
}
{
const o = {
a: [1, 2, [[
'Lorem ipsum dolor\nsit amet,\tconsectetur adipiscing elit, sed do ' +
'eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'test',
'foo']], 4],
b: new Map([['za', 1], ['zb', 'test']])
};
let out = util.inspect(o, { compact: true, depth: 5, breakLength: 80 });
let expect = [
'{ a:',
' [ 1,',
' 2,',
" [ [ 'Lorem ipsum dolor\\nsit amet,\\tconsectetur adipiscing elit, " +
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',",
" 'test',",
" 'foo' ] ],",
' 4 ],',
" b: Map(2) { 'za' => 1, 'zb' => 'test' } }",
].join('\n');
assert.strictEqual(out, expect);
out = util.inspect(o, { compact: false, depth: 5, breakLength: 60 });
expect = [
'{',
' a: [',
' 1,',
' 2,',
' [',
' [',
" 'Lorem ipsum dolor\\n' +",
" 'sit amet,\\tconsectetur adipiscing elit, sed do eiusmod " +
"tempor incididunt ut labore et dolore magna aliqua.',",
" 'test',",
" 'foo'",
' ]',
' ],',
' 4',
' ],',
' b: Map(2) {',
" 'za' => 1,",
" 'zb' => 'test'",
' }',
'}',
].join('\n');
assert.strictEqual(out, expect);
out = util.inspect(o.a[2][0][0], { compact: false, breakLength: 30 });
expect = [
"'Lorem ipsum dolor\\n' +",
" 'sit amet,\\tconsectetur adipiscing elit, sed do eiusmod tempor " +
"incididunt ut labore et dolore magna aliqua.'",
].join('\n');
assert.strictEqual(out, expect);
out = util.inspect(
'12345678901234567890123456789012345678901234567890',
{ compact: false, breakLength: 3 });
expect = "'12345678901234567890123456789012345678901234567890'";
assert.strictEqual(out, expect);
out = util.inspect(
'12 45 78 01 34 67 90 23 56 89 123456789012345678901234567890',
{ compact: false, breakLength: 3 });
expect = [
"'12 45 78 01 34 67 90 23 56 89 123456789012345678901234567890'",
].join('\n');
assert.strictEqual(out, expect);
o.a = () => {};
o.b = new Number(3);
out = util.inspect(o, { compact: false, breakLength: 3 });
expect = [
'{',
' a: [Function (anonymous)],',
' b: [Number: 3]',
'}',
].join('\n');
assert.strictEqual(out, expect);
out = util.inspect(o, { compact: false, breakLength: 3, showHidden: true });
expect = [
'{',
' a: [Function (anonymous)] {',
' [length]: 0,',
" [name]: ''",
' },',
' b: [Number: 3]',
'}',
].join('\n');
assert.strictEqual(out, expect);
o[util.inspect.custom] = () => 42;
out = util.inspect(o, { compact: false, breakLength: 3 });
expect = '42';
assert.strictEqual(out, expect);
o[util.inspect.custom] = () => '12 45 78 01 34 67 90 23';
out = util.inspect(o, { compact: false, breakLength: 3 });
expect = '12 45 78 01 34 67 90 23';
assert.strictEqual(out, expect);
o[util.inspect.custom] = () => ({ a: '12 45 78 01 34 67 90 23' });
out = util.inspect(o, { compact: false, breakLength: 3 });
expect = "{\n a: '12 45 78 01 34 67 90 23'\n}";
assert.strictEqual(out, expect);
}
{ const args = (function() { return arguments; })('a');
assert.strictEqual(util.inspect(args), "[Arguments] { '0': 'a' }");
}
{
const list = {};
let head = list;
for (let i = 0; i < 100000; i++)
head = head.next = {};
assert.strictEqual(
util.inspect(list),
'{ next: { next: { next: [Object] } } }'
);
const longList = util.inspect(list, { depth: Infinity });
const match = longList.match(/next/g);
assert(match.length > 500 && match.length < 10000);
}
assert.strictEqual(util.inspect("'"), '"\'"');
assert.strictEqual(util.inspect('"\''), '`"\'`');
assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'");
{
let obj = { class () {} };
assert.strictEqual(
util.inspect(obj),
'{ class: [Function: class] }'
);
obj = { class: () => {} };
assert.strictEqual(
util.inspect(obj),
'{ class: [Function: class] }'
);
obj = { ['class Foo {}']() {} };
assert.strictEqual(
util.inspect(obj),
"{ 'class Foo {}': [Function: class Foo {}] }"
);
function Foo() {}
Object.defineProperty(Foo, 'toString', { value: () => 'class Foo {}' });
assert.strictEqual(
util.inspect(Foo),
'[Function: Foo]'
);
function fn() {}
Object.defineProperty(fn, 'name', { value: 'class Foo {}' });
assert.strictEqual(
util.inspect(fn),
'[Function: class Foo {}]'
);
}
assert.strictEqual(inspect(1n), '1n');
assert.strictEqual(inspect(Object(-1n)), '[BigInt: -1n]');
assert.strictEqual(inspect(Object(13n)), '[BigInt: 13n]');
{
const obj = {};
Object.defineProperty(obj, 'Non\nenumerable\tkey', { value: true });
assert.strictEqual(
util.inspect(obj, { showHidden: true }),
'{ [Non\\nenumerable\\tkey]: true }'
);
}
{
const special = inspect.colors[inspect.styles.special];
const string = inspect.colors[inspect.styles.string];
assert.strictEqual(
inspect(new WeakSet(), { colors: true }),
`WeakSet { \u001b[${special[0]}m<items unknown>\u001b[${special[1]}m }`
);
assert.strictEqual(
inspect(new WeakMap(), { colors: true }),
`WeakMap { \u001b[${special[0]}m<items unknown>\u001b[${special[1]}m }`
);
const colors = Object.keys(inspect.colors);
const aliases = Object.getOwnPropertyNames(inspect.colors)
.filter((c) => !colors.includes(c));
assert(!colors.includes('grey'));
assert(colors.includes('gray'));
for (const alias of aliases) {
assert(Array.isArray(inspect.colors[alias]));
}
[
'black',
'red',
'green',
'yellow',
'blue',
'magenta',
'cyan',
'white',
].forEach((color, i) => {
assert.deepStrictEqual(inspect.colors[color], [30 + i, 39]);
assert.deepStrictEqual(inspect.colors[`${color}Bright`], [90 + i, 39]);
const bgColor = `bg${color[0].toUpperCase()}${color.slice(1)}`;
assert.deepStrictEqual(inspect.colors[bgColor], [40 + i, 49]);
assert.deepStrictEqual(inspect.colors[`${bgColor}Bright`], [100 + i, 49]);
});
const stringStyle = inspect.styles.string;
inspect.styles.string = 'UNKNOWN';
assert.strictEqual(inspect('foobar', { colors: true }), "'foobar'");
inspect.styles.string = stringStyle;
}
assert.strictEqual(
inspect([1, 3, 2], { sorted: true }),
inspect([1, 3, 2])
);
assert.strictEqual(
inspect({ c: 3, a: 1, b: 2 }, { sorted: true }),
'{ a: 1, b: 2, c: 3 }'
);
assert.strictEqual(
inspect(
{ a200: 4, a100: 1, a102: 3, a101: 2 },
{ sorted(a, b) { return b.localeCompare(a); } }
),
'{ a200: 4, a102: 3, a101: 2, a100: 1 }'
);
{
let foo = 1;
const get = { get foo() { return foo; } };
const getset = {
get foo() { return foo; },
set foo(val) { foo = val; },
get inc() { return ++foo; }
};
const thrower = { get foo() { throw new Error('Oops'); } };
assert.strictEqual(
inspect(get, { getters: true, colors: true }),
'{ foo: \u001b[36m[Getter:\u001b[39m ' +
'\u001b[33m1\u001b[39m\u001b[36m]\u001b[39m }');
assert.strictEqual(
inspect(thrower, { getters: true }),
'{ foo: [Getter: <Inspection threw (Oops)>] }');
assert.strictEqual(
inspect(getset, { getters: true }),
'{ foo: [Getter/Setter: 1], inc: [Getter: 2] }');
assert.strictEqual(
inspect(getset, { getters: 'get' }),
'{ foo: [Getter/Setter], inc: [Getter: 3] }');
assert.strictEqual(
inspect(getset, { getters: 'set' }),
'{ foo: [Getter/Setter: 3], inc: [Getter] }');
getset.foo = new Set([[{ a: true }, 2, {}], 'foobar', { x: 1 }]);
}
{
let obj = {
a: {
b: {
x: 5,
c: {
x: '10000000000000000 00000000000000000 '.repeat(1e1),
d: 2,
e: 3
}
}
},
b: [
1,
2,
[ 1, 2, { a: 1, b: 2, c: 3 } ],
],
c: ['foo', 4, 444444],
d: Array.from({ length: 101 }).map((e, i) => {
return i % 2 === 0 ? i * i : i;
}),
e: Array(6).fill('foobar'),
f: Array(9).fill('foobar'),
g: Array(21).fill('foobar baz'),
h: [100].concat(Array.from({ length: 9 }).map((e, n) => (n))),
long: Array(9).fill('This text is too long for grouping!')
};
let out = util.inspect(obj, { compact: 3, depth: 10, breakLength: 60 });
let expected = [
'{',
' a: {',
' b: {',
' x: 5,',
' c: {',
" x: '10000000000000000 00000000000000000 10000000000000000 " +
'00000000000000000 10000000000000000 00000000000000000 ' +
'10000000000000000 00000000000000000 10000000000000000 ' +
'00000000000000000 10000000000000000 00000000000000000 ' +
'10000000000000000 00000000000000000 10000000000000000 ' +
'00000000000000000 10000000000000000 00000000000000000 ' +
"10000000000000000 00000000000000000 ',",
' d: 2,',
' e: 3',
' }',
' }',
' },',
' b: [ 1, 2, [ 1, 2, { a: 1, b: 2, c: 3 } ] ],',
" c: [ 'foo', 4, 444444 ],",
' d: [',
' 0, 1, 4, 3, 16, 5, 36, 7, 64,',
' 9, 100, 11, 144, 13, 196, 15, 256, 17,',
' 324, 19, 400, 21, 484, 23, 576, 25, 676,',
' 27, 784, 29, 900, 31, 1024, 33, 1156, 35,',
' 1296, 37, 1444, 39, 1600, 41, 1764, 43, 1936,',
' 45, 2116, 47, 2304, 49, 2500, 51, 2704, 53,',
' 2916, 55, 3136, 57, 3364, 59, 3600, 61, 3844,',
' 63, 4096, 65, 4356, 67, 4624, 69, 4900, 71,',
' 5184, 73, 5476, 75, 5776, 77, 6084, 79, 6400,',
' 81, 6724, 83, 7056, 85, 7396, 87, 7744, 89,',
' 8100, 91, 8464, 93, 8836, 95, 9216, 97, 9604,',
' 99,',
' ... 1 more item',
' ],',
' e: [',
" 'foobar',",
" 'foobar',",
" 'foobar',",
" 'foobar',",
" 'foobar',",
" 'foobar'",
' ],',
' f: [',
" 'foobar', 'foobar',",
" 'foobar', 'foobar',",
" 'foobar', 'foobar',",
" 'foobar', 'foobar',",
" 'foobar'",
' ],',
' g: [',
" 'foobar baz', 'foobar baz',",
" 'foobar baz', 'foobar baz',",
" 'foobar baz', 'foobar baz',",
" 'foobar baz', 'foobar baz',",
" 'foobar baz', 'foobar baz',",
" 'foobar baz', 'foobar baz',",
" 'foobar baz', 'foobar baz',",
" 'foobar baz', 'foobar baz',",
" 'foobar baz', 'foobar baz',",
" 'foobar baz', 'foobar baz',",
" 'foobar baz'",
' ],',
' h: [',
' 100, 0, 1, 2, 3,',
' 4, 5, 6, 7, 8',
' ],',
' long: [',
" 'This text is too long for grouping!',",
" 'This text is too long for grouping!',",
" 'This text is too long for grouping!',",
" 'This text is too long for grouping!',",
" 'This text is too long for grouping!',",
" 'This text is too long for grouping!',",
" 'This text is too long for grouping!',",
" 'This text is too long for grouping!',",
" 'This text is too long for grouping!'",
' ]',
'}',
].join('\n');
obj = [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 123456789,
];
out = util.inspect(obj, { compact: 3 });
expected = [
'[',
' 1, 1, 1, 1,',
' 1, 1, 1, 1,',
' 1, 1, 1, 1,',
' 1, 1, 1, 1,',
' 1, 1, 1, 1,',
' 1, 1, 1, 1,',
' 1, 1, 123456789',
']',
].join('\n');
obj = [
'123', '123', '123', '123', 'あああ',
'123', '123', '123', '123', 'あああ',
];
out = util.inspect(obj, { compact: 3 });
expected = [
'[',
" '123', '123',",
" '123', '123',",
" 'あああ', '123',",
" '123', '123',",
" '123', 'あああ'",
']',
].join('\n');
obj = {
a: {
b: {
x: 5,
c: {
d: 2,
e: 3
}
}
},
b: Array.from({ length: 9 }).map((e, n) => {
return n % 2 === 0 ? 'foobar' : 'baz';
})
};
out = util.inspect(obj, { compact: 1, breakLength: Infinity, colors: true });
expected = [
'{',
' a: {',
' b: { x: \u001b[33m5\u001b[39m, c: \u001b[36m[Object]\u001b[39m }',
' },',
' b: [',
" \u001b[32m'foobar'\u001b[39m, \u001b[32m'baz'\u001b[39m,",
" \u001b[32m'foobar'\u001b[39m, \u001b[32m'baz'\u001b[39m,",
" \u001b[32m'foobar'\u001b[39m, \u001b[32m'baz'\u001b[39m,",
" \u001b[32m'foobar'\u001b[39m, \u001b[32m'baz'\u001b[39m,",
" \u001b[32m'foobar'\u001b[39m",
' ]',
'}',
].join('\n');
obj = Array.from({ length: 60 }).map((e, i) => i);
out = util.inspect(obj, { compact: 1, breakLength: Infinity, colors: true });
expected = [
'[',
' \u001b[33m0\u001b[39m, \u001b[33m1\u001b[39m, \u001b[33m2\u001b[39m, \u001b[33m3\u001b[39m,',
' \u001b[33m4\u001b[39m, \u001b[33m5\u001b[39m, \u001b[33m6\u001b[39m, \u001b[33m7\u001b[39m,',
' \u001b[33m8\u001b[39m, \u001b[33m9\u001b[39m, \u001b[33m10\u001b[39m, \u001b[33m11\u001b[39m,',
' \u001b[33m12\u001b[39m, \u001b[33m13\u001b[39m, \u001b[33m14\u001b[39m, \u001b[33m15\u001b[39m,',
' \u001b[33m16\u001b[39m, \u001b[33m17\u001b[39m, \u001b[33m18\u001b[39m, \u001b[33m19\u001b[39m,',
' \u001b[33m20\u001b[39m, \u001b[33m21\u001b[39m, \u001b[33m22\u001b[39m, \u001b[33m23\u001b[39m,',
' \u001b[33m24\u001b[39m, \u001b[33m25\u001b[39m, \u001b[33m26\u001b[39m, \u001b[33m27\u001b[39m,',
' \u001b[33m28\u001b[39m, \u001b[33m29\u001b[39m, \u001b[33m30\u001b[39m, \u001b[33m31\u001b[39m,',
' \u001b[33m32\u001b[39m, \u001b[33m33\u001b[39m, \u001b[33m34\u001b[39m, \u001b[33m35\u001b[39m,',
' \u001b[33m36\u001b[39m, \u001b[33m37\u001b[39m, \u001b[33m38\u001b[39m, \u001b[33m39\u001b[39m,',
' \u001b[33m40\u001b[39m, \u001b[33m41\u001b[39m, \u001b[33m42\u001b[39m, \u001b[33m43\u001b[39m,',
' \u001b[33m44\u001b[39m, \u001b[33m45\u001b[39m, \u001b[33m46\u001b[39m, \u001b[33m47\u001b[39m,',
' \u001b[33m48\u001b[39m, \u001b[33m49\u001b[39m, \u001b[33m50\u001b[39m, \u001b[33m51\u001b[39m,',
' \u001b[33m52\u001b[39m, \u001b[33m53\u001b[39m, \u001b[33m54\u001b[39m, \u001b[33m55\u001b[39m,',
' \u001b[33m56\u001b[39m, \u001b[33m57\u001b[39m, \u001b[33m58\u001b[39m, \u001b[33m59\u001b[39m',
']',
].join('\n');
out = util.inspect([1, 2, 3, 4], { compact: 1, colors: true });
expected = '[ \u001b[33m1\u001b[39m, \u001b[33m2\u001b[39m, ' +
'\u001b[33m3\u001b[39m, \u001b[33m4\u001b[39m ]';
assert.strictEqual(out, expected);
obj = [
'Object', 'Function', 'Array',
'Number', 'parseFloat', 'parseInt',
'Infinity', 'NaN', 'undefined',
'Boolean', 'String', 'Symbol',
'Date', 'Promise', 'RegExp',
'Error', 'EvalError', 'RangeError',
'ReferenceError', 'SyntaxError', 'TypeError',
'URIError', 'JSON', 'Math',
'console', 'Intl', 'ArrayBuffer',
'Uint8Array', 'Int8Array', 'Uint16Array',
'Int16Array', 'Uint32Array', 'Int32Array',
'Float32Array', 'Float64Array', 'Uint8ClampedArray',
'BigUint64Array', 'BigInt64Array', 'DataView',
'Map', 'BigInt', 'Set',
'WeakMap', 'WeakSet', 'Proxy',
'Reflect', 'decodeURI', 'decodeURIComponent',
'encodeURI', 'encodeURIComponent', 'escape',
'unescape', 'eval', 'isFinite',
'isNaN', 'SharedArrayBuffer', 'Atomics',
'globalThis', 'WebAssembly', 'global',
'process', 'Buffer', 'URL',
'URLSearchParams', 'TextEncoder', 'TextDecoder',
'clearInterval', 'clearTimeout', 'setInterval',
'setTimeout', 'queueMicrotask', 'clearImmediate',
'setImmediate', 'module', 'require',
'assert', 'async_hooks', 'buffer',
'child_process', 'cluster', 'crypto',
'dgram', 'dns', 'domain',
'events', 'fs', 'http',
'http2', 'https', 'inspector',
'net', 'os', 'path',
'perf_hooks', 'punycode', 'querystring',
'readline', 'repl', 'stream',
'string_decoder', 'tls', 'trace_events',
'tty', 'url', 'v8',
'vm', 'worker_threads', 'zlib',
'_', '_error', 'util',
];
out = util.inspect(
obj,
{ compact: 3, breakLength: 80, maxArrayLength: 250 }
);
expected = [
'[',
" 'Object', 'Function', 'Array',",
" 'Number', 'parseFloat', 'parseInt',",
" 'Infinity', 'NaN', 'undefined',",
" 'Boolean', 'String', 'Symbol',",
" 'Date', 'Promise', 'RegExp',",
" 'Error', 'EvalError', 'RangeError',",
" 'ReferenceError', 'SyntaxError', 'TypeError',",
" 'URIError', 'JSON', 'Math',",
" 'console', 'Intl', 'ArrayBuffer',",
" 'Uint8Array', 'Int8Array', 'Uint16Array',",
" 'Int16Array', 'Uint32Array', 'Int32Array',",
" 'Float32Array', 'Float64Array', 'Uint8ClampedArray',",
" 'BigUint64Array', 'BigInt64Array', 'DataView',",
" 'Map', 'BigInt', 'Set',",
" 'WeakMap', 'WeakSet', 'Proxy',",
" 'Reflect', 'decodeURI', 'decodeURIComponent',",
" 'encodeURI', 'encodeURIComponent', 'escape',",
" 'unescape', 'eval', 'isFinite',",
" 'isNaN', 'SharedArrayBuffer', 'Atomics',",
" 'globalThis', 'WebAssembly', 'global',",
" 'process', 'Buffer', 'URL',",
" 'URLSearchParams', 'TextEncoder', 'TextDecoder',",
" 'clearInterval', 'clearTimeout', 'setInterval',",
" 'setTimeout', 'queueMicrotask', 'clearImmediate',",
" 'setImmediate', 'module', 'require',",
" 'assert', 'async_hooks', 'buffer',",
" 'child_process', 'cluster', 'crypto',",
" 'dgram', 'dns', 'domain',",
" 'events', 'fs', 'http',",
" 'http2', 'https', 'inspector',",
" 'net', 'os', 'path',",
" 'perf_hooks', 'punycode', 'querystring',",
" 'readline', 'repl', 'stream',",
" 'string_decoder', 'tls', 'trace_events',",
" 'tty', 'url', 'v8',",
" 'vm', 'worker_threads', 'zlib',",
" '_', '_error', 'util'",
']',
].join('\n');
}
{
class Foo extends Map {
prop = false;
prop2 = true;
get abc() {
return true;
}
get def() {
return false;
}
set def(v) {}
get xyz() {
return 'Should be ignored';
}
func(a) {}
[util.inspect.custom]() {
return this;
}
}
class Bar extends Foo {
abc = true;
prop = true;
get xyz() {
return 'YES!';
}
[util.inspect.custom]() {
return this;
}
}
const bar = new Bar();
assert.strictEqual(
inspect(bar),
'Bar(0) [Map] { prop: true, prop2: true, abc: true }'
);
}
{
function Func() {}
Func.prototype = null;
const object = {};
object.constructor = Func;
assert.strictEqual(util.inspect(object), '{ constructor: [Function: Func] }');
}
{
const colors = util.inspect.colors;
const originalValue = colors.gray;
assert.strictEqual(colors.grey, colors.gray);
colors.gray = [0, 0];
assert.deepStrictEqual(colors.gray, [0, 0]);
assert.strictEqual(colors.grey, colors.gray);
colors.grey = [1, 1];
assert.deepStrictEqual(colors.grey, [1, 1]);
assert.strictEqual(colors.grey, colors.gray);
colors.gray = originalValue;
assert.deepStrictEqual(colors.gray, originalValue);
assert.strictEqual(colors.grey, colors.gray);
}
{
assert.strictEqual(util.inspect('bl', { maxStringLength: 1 }),
"'b'... 1 more character");
}
{
const x = 'a'.repeat(1e6);
assert(util.inspect(x).endsWith('... 990000 more characters'));
assert.strictEqual(
util.inspect(x, { maxStringLength: 4 }),
"'aaaa'... 999996 more characters"
);
assert.match(util.inspect(x, { maxStringLength: null }), /a'$/);
}
{
function Fhqwhgads() {}
const sterrance = new Fhqwhgads();
sterrance.constructor = Fhqwhgads;
assert.strictEqual(
util.inspect(sterrance, { showHidden: true }),
'Fhqwhgads {\n' +
' constructor: <ref *1> [Function: Fhqwhgads] {\n' +
' [length]: 0,\n' +
" [name]: 'Fhqwhgads',\n" +
' [prototype]: { [constructor]: [Circular *1] }\n' +
' }\n' +
'}'
);
}
{
const obj = Array(9).fill('fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf');
assert.strictEqual(
util.inspect(obj, { breakLength: 256 }),
'[\n' +
" 'fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf',\n" +
" 'fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf',\n" +
" 'fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf',\n" +
" 'fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf',\n" +
" 'fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf',\n" +
" 'fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf',\n" +
" 'fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf',\n" +
" 'fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf',\n" +
" 'fhqwhgadshgnsdhjsdbkhsdabkfabkveybvf'\n" +
']'
);
}
{
assert.strictEqual(
util.inspect({ ['__proto__']: { a: 1 } }),
"{ ['__proto__']: { a: 1 } }"
);
}