diff options
author | Evan Lucas <evanlucas@me.com> | 2015-10-05 16:29:27 -0500 |
---|---|---|
committer | Evan Lucas <evanlucas@me.com> | 2015-10-05 20:24:08 -0500 |
commit | 089d6886178864b56fdd5dc2bcfc8f207aa4326c (patch) | |
tree | 23860c4efb0728f14037f83199f85ec5aced2311 /test | |
parent | 77a10ed05f1e413818d29f07cbb268108b1f08fa (diff) | |
download | node-new-089d6886178864b56fdd5dc2bcfc8f207aa4326c.tar.gz |
util: fix check for Array constructor
In the event an Array is created in a Debug context, the constructor
will be Array, but !== Array. This adds a check
constructor.name === 'Array' to handle edge cases like that.
PR-URL: https://github.com/nodejs/node/pull/3119
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-util-inspect.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 58a4c8a2f2..aa6c764491 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -23,6 +23,19 @@ assert.equal(util.inspect(a), '[ \'foo\', , \'baz\' ]'); assert.equal(util.inspect(a, true), '[ \'foo\', , \'baz\', [length]: 3 ]'); assert.equal(util.inspect(new Array(5)), '[ , , , , ]'); +// test for Array constructor in different context +const Debug = require('vm').runInDebugContext('Debug'); +var map = new Map(); +map.set(1, 2); +var mirror = Debug.MakeMirror(map.entries(), true); +var vals = mirror.preview(); +var valsOutput = []; +for (let o of vals) { + valsOutput.push(o); +} + +assert.strictEqual(util.inspect(valsOutput), '[ [ 1, 2 ] ]'); + // test for property descriptors var getter = Object.create(null, { a: { |