Skip to content

Commit

Permalink
test: increase coverage for util.inspect()
Browse files Browse the repository at this point in the history
Confirm that own constructor value displays correctly.

Refs: https://coverage.nodejs.org/coverage-0d468ab200584c3a/lib/internal/util/inspect.js.html#L550

PR-URL: #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>
  • Loading branch information
Trott authored and targos committed May 1, 2021
1 parent 2bbf253 commit cb530d2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3001,3 +3001,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' +
'}'
);
}

0 comments on commit cb530d2

Please sign in to comment.