diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 3da292fc663..1aaac979d78 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -3258,6 +3258,13 @@ assert.strictEqual( util.inspect({ ['__proto__']: { a: 1 } }), "{ ['__proto__']: { a: 1 } }" ); + + const o = { ['__proto__']: { a: 1 } }; + Object.defineProperty(o, '__proto__', { enumerable: false }); + assert.strictEqual( + util.inspect(o, { showHidden: true }), + "{ ['__proto__']: { a: 1 } }" + ); } { @@ -3323,3 +3330,26 @@ assert.strictEqual( } }), '{ [Symbol(Symbol.iterator)]: [Getter] }'); } + +{ + const sym = Symbol('bar'); + const o = { + 'foo': 0, + 'Symbol(foo)': 0, + [Symbol('foo')]: 0, + [Symbol('foo()')]: 0, + [sym]: 0, + }; + Object.defineProperty(o, sym, { enumerable: false }); + + assert.strictEqual( + util.inspect(o, { showHidden: true }), + '{\n' + + ' foo: 0,\n' + + " 'Symbol(foo)': 0,\n" + + ' [Symbol(foo)]: 0,\n' + + ' [Symbol(foo())]: 0,\n' + + ' [Symbol(bar)]: 0\n' + + '}', + ); +}