From b613950016bc6f5f773916f2399adfe419c93861 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 22 Nov 2020 07:00:49 -0800 Subject: [PATCH] test: increase coverage for util.inspect() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confirm that own constructor value displays correctly. Refs: https://coverage.nodejs.org/coverage-0d468ab200584c3a/lib/internal/util/inspect.js.html#L550 PR-URL: https://github.com/nodejs/node/pull/36228 Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: Benjamin Gruenbaum Reviewed-By: Juan José Arboleda Reviewed-By: Michael Dawson Reviewed-By: James M Snell --- test/parallel/test-util-inspect.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 634f27690e5a59..8961b6cef20bd5 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -2991,3 +2991,23 @@ assert.strictEqual( // Consistency check. assert(fullObjectGraph(global).has(Function.prototype)); } + +{ + // Confirm that own constructor value displays correctly. + + function Fhqwhgads() {} + + const sterrance = new Fhqwhgads(); + sterrance.constructor = Fhqwhgads; + + assert.strictEqual( + util.inspect(sterrance, { showHidden: true }), + 'Fhqwhgads {\n' + + ' constructor: [Function: Fhqwhgads] {\n' + + ' [length]: 0,\n' + + " [name]: 'Fhqwhgads',\n" + + ' [prototype]: { [constructor]: [Circular *1] }\n' + + ' }\n' + + '}' + ); +}