Skip to content

Commit

Permalink
test: add test for util.inspect
Browse files Browse the repository at this point in the history
add test case for util.inspect with 'depth' option set to 'null'
 and with that has a custom inspect function attached

PR-URL: #27906
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
  • Loading branch information
Nievl authored and targos committed May 31, 2019
1 parent f621b8f commit 3ba354a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; } };
Expand Down

0 comments on commit 3ba354a

Please sign in to comment.