Browse Source

test: check util.inspect circular Set and Map refs

Ref: https://github.com/nodejs/node/pull/14775
PR-URL: https://github.com/nodejs/node/pull/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>
canary-base
Ruben Bridgewater 7 years ago
committed by Anna Henningsen
parent
commit
f853baf544
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 19
      test/parallel/test-util-inspect.js

19
test/parallel/test-util-inspect.js

@ -799,6 +799,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 {}');
@ -810,6 +817,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);

Loading…
Cancel
Save