summaryrefslogtreecommitdiff
path: root/test/parallel/test-util-inspect.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-01-12 00:15:10 +0100
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-01-18 08:03:25 +0100
commit2c0a75118cd6a2eaf6b45fe8c67336f44c86ab0f (patch)
tree58b5f79ec97025d0935907794e0219fb29d8d399 /test/parallel/test-util-inspect.js
parent27f9a55cf66390195ad36eae0eb21fb4d07bb500 (diff)
downloadandroid-node-v8-2c0a75118cd6a2eaf6b45fe8c67336f44c86ab0f.tar.gz
android-node-v8-2c0a75118cd6a2eaf6b45fe8c67336f44c86ab0f.tar.bz2
android-node-v8-2c0a75118cd6a2eaf6b45fe8c67336f44c86ab0f.zip
util: fix iterable types with special prototype
The fallback should only be taken for a null prototype. If an iterable data type (e.g., Array) has a prototype without `Symbol.iterator`, just try the best to visualize it as object. PR-URL: https://github.com/nodejs/node/pull/25457 Fixes: https://github.com/nodejs/node/issues/25451 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-util-inspect.js')
-rw-r--r--test/parallel/test-util-inspect.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index c9ca8f5787..76f8caa31a 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -1853,6 +1853,16 @@ assert.strictEqual(
util.inspect(new StorageObject()),
'<[Object: null prototype] {}> {}'
);
+
+ obj = [1, 2, 3];
+ Object.setPrototypeOf(obj, Number.prototype);
+ assert.strictEqual(inspect(obj), "Number { '0': 1, '1': 2, '2': 3 }");
+
+ Object.setPrototypeOf(obj, Object.create(null));
+ assert.strictEqual(
+ inspect(obj),
+ "<[Object: null prototype] {}> { '0': 1, '1': 2, '2': 3 }"
+ );
}
// Check that the fallback always works.