test: add test for util.inspect

add test case for util.inspect with 'depth' option set to 'null'
 and with that has a custom inspect function attached

PR-URL: https://github.com/nodejs/node/pull/27906
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
This commit is contained in:
Levin Eugene 2019-05-26 17:24:33 +03:00 committed by ZYSzys
parent fc7c5b9795
commit 3b50bded08

View File

@ -852,6 +852,13 @@ util.inspect({ hasOwnProperty: null });
util.inspect(subject, { customInspectOptions: true, seen: null });
}
{
const subject = { [util.inspect.custom]: common.mustCall((depth) => {
assert.strictEqual(depth, null);
}) };
util.inspect(subject, { depth: null });
}
{
// Returning `this` from a custom inspection function works.
const subject = { a: 123, [util.inspect.custom]() { return this; } };