summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-12-12 00:25:32 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-12-16 12:32:58 +0100
commit02b66b5b866bd8398e7d815d3715ba3f94a5cf65 (patch)
treeb14da4f33c59b0a4e94b5c19999564cc13840913 /test
parent5f4fa0756b6961cf73a224f4307eaba13b9f9d40 (diff)
downloadandroid-node-v8-02b66b5b866bd8398e7d815d3715ba3f94a5cf65.tar.gz
android-node-v8-02b66b5b866bd8398e7d815d3715ba3f94a5cf65.tar.bz2
android-node-v8-02b66b5b866bd8398e7d815d3715ba3f94a5cf65.zip
util: inspect all prototypes
It is currently difficult to distinguish multiple objects from each other because the prototype is not properly inspected. From now on all prototypes will be inspected, even if we do not fully know how they will look like / what their shape really is. PR-URL: https://github.com/nodejs/node/pull/24974 Fixes: https://github.com/nodejs/node/issues/24917 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-util-inspect.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index 20b03d2dd0..0d9cbdbe9d 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -1738,19 +1738,34 @@ assert.strictEqual(
);
}
-// Manipulate the prototype to one that we can not handle.
+// Manipulate the prototype in weird ways.
{
let obj = { a: true };
let value = (function() { return function() {}; })();
Object.setPrototypeOf(value, null);
Object.setPrototypeOf(obj, value);
- assert.strictEqual(util.inspect(obj), '{ a: true }');
+ assert.strictEqual(util.inspect(obj), '<[Function]> { a: true }');
+ assert.strictEqual(
+ util.inspect(obj, { colors: true }),
+ '<\u001b[36m[Function]\u001b[39m> { a: \u001b[33mtrue\u001b[39m }'
+ );
obj = { a: true };
value = [];
Object.setPrototypeOf(value, null);
Object.setPrototypeOf(obj, value);
- assert.strictEqual(util.inspect(obj), '{ a: true }');
+ assert.strictEqual(
+ util.inspect(obj),
+ '<[Array: null prototype] []> { a: true }'
+ );
+
+ function StorageObject() {}
+ StorageObject.prototype = Object.create(null);
+ assert.strictEqual(
+ util.inspect(new StorageObject()),
+ '<[Object: null prototype] {}> {}'
+ );
+
}
// Check that the fallback always works.