mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
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>
This commit is contained in:
1 parent
c3c6cb1c13
commit
4f49ae52f8
1 file changed
+19
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user