Permalink
Browse files

test: check util.inspect circular Set and Map refs

Ref: #14775
PR-URL: #14790
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information...
BridgeAR authored and MylesBorins committed Aug 11, 2017
1 parent c3c6cb1 commit 4f49ae52f8d3e445a0655ccbaaefb2597d2dca56
Showing with 19 additions and 0 deletions.
  1. +19 −0 test/parallel/test-util-inspect.js
@@ -790,6 +790,13 @@ if (typeof Symbol !== 'undefined') {
);
}
// Test circular Set
{
const set = new Set();
set.add(set);
assert.strictEqual(util.inspect(set), 'Set { [Circular] }');
}
// test Map
{
assert.strictEqual(util.inspect(new Map()), 'Map {}');
@@ -801,6 +808,18 @@ if (typeof Symbol !== 'undefined') {
'Map { \'foo\' => null, [size]: 1, bar: 42 }');
}
// Test circular Map
{
const map = new Map();
map.set(map, 'map');
assert.strictEqual(util.inspect(map), "Map { [Circular] => 'map' }");
map.set(map, map);
assert.strictEqual(util.inspect(map), 'Map { [Circular] => [Circular] }');
map.delete(map);
map.set('map', map);
assert.strictEqual(util.inspect(map), "Map { 'map' => [Circular] }");
}
// test Promise
{
const resolved = Promise.resolve(3);

0 comments on commit 4f49ae5

Please sign in to comment.