File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -799,6 +799,13 @@ if (typeof Symbol !== 'undefined') {
799799 ) ;
800800}
801801
802+ // Test circular Set
803+ {
804+ const set = new Set ( ) ;
805+ set . add ( set ) ;
806+ assert . strictEqual ( util . inspect ( set ) , 'Set { [Circular] }' ) ;
807+ }
808+
802809// test Map
803810{
804811 assert . strictEqual ( util . inspect ( new Map ( ) ) , 'Map {}' ) ;
@@ -810,6 +817,18 @@ if (typeof Symbol !== 'undefined') {
810817 'Map { \'foo\' => null, [size]: 1, bar: 42 }' ) ;
811818}
812819
820+ // Test circular Map
821+ {
822+ const map = new Map ( ) ;
823+ map . set ( map , 'map' ) ;
824+ assert . strictEqual ( util . inspect ( map ) , "Map { [Circular] => 'map' }" ) ;
825+ map . set ( map , map ) ;
826+ assert . strictEqual ( util . inspect ( map ) , 'Map { [Circular] => [Circular] }' ) ;
827+ map . delete ( map ) ;
828+ map . set ( 'map' , map ) ;
829+ assert . strictEqual ( util . inspect ( map ) , "Map { 'map' => [Circular] }" ) ;
830+ }
831+
813832// test Promise
814833{
815834 const resolved = Promise . resolve ( 3 ) ;
You can’t perform that action at this time.
0 commit comments