test: increase coverage for util.inspect()

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 <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Rich Trott
2020-11-22 07:00:49 -08:00
parent 49abda71e2
commit c19ea7bd81

View File

@@ -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: <ref *1> [Function: Fhqwhgads] {\n' +
' [length]: 0,\n' +
" [name]: 'Fhqwhgads',\n" +
' [prototype]: { [constructor]: [Circular *1] }\n' +
' }\n' +
'}'
);
}