Skip to content

Commit 23275cc

Browse files
ljharbnodejs-github-bot
authored andcommitted
test: add test case for util.inspect
PR-URL: #55778 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
1 parent 9f2885a commit 23275cc

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/parallel/test-util-inspect.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3258,6 +3258,13 @@ assert.strictEqual(
32583258
util.inspect({ ['__proto__']: { a: 1 } }),
32593259
"{ ['__proto__']: { a: 1 } }"
32603260
);
3261+
3262+
const o = { ['__proto__']: { a: 1 } };
3263+
Object.defineProperty(o, '__proto__', { enumerable: false });
3264+
assert.strictEqual(
3265+
util.inspect(o, { showHidden: true }),
3266+
"{ ['__proto__']: { a: 1 } }"
3267+
);
32613268
}
32623269

32633270
{
@@ -3323,3 +3330,26 @@ assert.strictEqual(
33233330
}
33243331
}), '{ [Symbol(Symbol.iterator)]: [Getter] }');
33253332
}
3333+
3334+
{
3335+
const sym = Symbol('bar');
3336+
const o = {
3337+
'foo': 0,
3338+
'Symbol(foo)': 0,
3339+
[Symbol('foo')]: 0,
3340+
[Symbol('foo()')]: 0,
3341+
[sym]: 0,
3342+
};
3343+
Object.defineProperty(o, sym, { enumerable: false });
3344+
3345+
assert.strictEqual(
3346+
util.inspect(o, { showHidden: true }),
3347+
'{\n' +
3348+
' foo: 0,\n' +
3349+
" 'Symbol(foo)': 0,\n" +
3350+
' [Symbol(foo)]: 0,\n' +
3351+
' [Symbol(foo())]: 0,\n' +
3352+
' [Symbol(bar)]: 0\n' +
3353+
'}',
3354+
);
3355+
}

0 commit comments

Comments
 (0)