summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2020-11-19 16:36:01 +0100
committerNode.js GitHub Bot <github-bot@iojs.org>2020-12-12 20:58:02 +0000
commit1e665095c874a9bd21e7c88ce62ade991989bcf5 (patch)
tree2efd1be4d8c1f1181afa285a2885996cb304fcec /test
parentf78da00ab7dd1341d8a2e7b4447fdc1c7b75913d (diff)
downloadios-node-v8-1e665095c874a9bd21e7c88ce62ade991989bcf5.tar.gz
ios-node-v8-1e665095c874a9bd21e7c88ce62ade991989bcf5.tar.bz2
ios-node-v8-1e665095c874a9bd21e7c88ce62ade991989bcf5.zip
util: fix instanceof checks with null prototypes during inspection
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de> Fixes: https://github.com/nodejs/node/issues/35730 PR-URL: https://github.com/nodejs/node/pull/36178 Fixes: https://github.com/nodejs/node/issues/36151 Refs: https://github.com/nodejs/node/pull/35754 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-util-inspect.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index e51b96fffd..b14cab3d13 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -2866,6 +2866,17 @@ assert.strictEqual(
);
}
+// Check that prototypes with a null prototype are inspectable.
+// Regression test for https://github.com/nodejs/node/issues/35730
+{
+ function Func() {}
+ Func.prototype = null;
+ const object = {};
+ object.constructor = Func;
+
+ assert.strictEqual(util.inspect(object), '{ constructor: [Function: Func] }');
+}
+
// Test changing util.inspect.colors colors and aliases.
{
const colors = util.inspect.colors;