From 3ba354aaaa412d6927048f2594921b40a5157f21 Mon Sep 17 00:00:00 2001 From: Levin Eugene Date: Sun, 26 May 2019 17:24:33 +0300 Subject: [PATCH] test: add test for util.inspect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Ujjwal Sharma Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Rich Trott Reviewed-By: Yongsheng Zhang --- test/parallel/test-util-inspect.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index cfd962097810ce..57994af20911d7 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -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; } };