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 @@ -790,6 +790,13 @@ if (typeof Symbol !== 'undefined') {
790790 ) ;
791791}
792792
793+ // Test circular Set
794+ {
795+ const set = new Set ( ) ;
796+ set . add ( set ) ;
797+ assert . strictEqual ( util . inspect ( set ) , 'Set { [Circular] }' ) ;
798+ }
799+
793800// test Map
794801{
795802 assert . strictEqual ( util . inspect ( new Map ( ) ) , 'Map {}' ) ;
@@ -801,6 +808,18 @@ if (typeof Symbol !== 'undefined') {
801808 'Map { \'foo\' => null, [size]: 1, bar: 42 }' ) ;
802809}
803810
811+ // Test circular Map
812+ {
813+ const map = new Map ( ) ;
814+ map . set ( map , 'map' ) ;
815+ assert . strictEqual ( util . inspect ( map ) , "Map { [Circular] => 'map' }" ) ;
816+ map . set ( map , map ) ;
817+ assert . strictEqual ( util . inspect ( map ) , 'Map { [Circular] => [Circular] }' ) ;
818+ map . delete ( map ) ;
819+ map . set ( 'map' , map ) ;
820+ assert . strictEqual ( util . inspect ( map ) , "Map { 'map' => [Circular] }" ) ;
821+ }
822+
804823// test Promise
805824{
806825 const resolved = Promise . resolve ( 3 ) ;
You can’t perform that action at this time.
0 commit comments