test: add test case for util.inspect

PR-URL: https://github.com/nodejs/node/pull/55778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
Jordan Harband 2024-11-08 13:15:37 +00:00 committed by Node.js GitHub Bot
parent 9f2885ad21
commit 23275cc7bc

View File

@ -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' +
'}',
);
}