File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -517,7 +517,7 @@ def json_transform(state)
517517
518518 if empty?
519519 state . depth -= 1
520- return '{}'
520+ return + '{}'
521521 end
522522
523523 delim = ",#{ state . object_nl } "
@@ -609,7 +609,7 @@ def json_transform(state)
609609
610610 if empty?
611611 state . depth -= 1
612- return '[]'
612+ return + '[]'
613613 end
614614
615615 result = '[' . dup
@@ -734,17 +734,17 @@ def to_json(state = nil, *args)
734734
735735 module TrueClass
736736 # Returns a JSON string for true: 'true'.
737- def to_json ( *) 'true' end
737+ def to_json ( *) + 'true' end
738738 end
739739
740740 module FalseClass
741741 # Returns a JSON string for false: 'false'.
742- def to_json ( *) 'false' end
742+ def to_json ( *) + 'false' end
743743 end
744744
745745 module NilClass
746746 # Returns a JSON string for nil: 'null'.
747- def to_json ( *) 'null' end
747+ def to_json ( *) + 'null' end
748748 end
749749 end
750750 end
Original file line number Diff line number Diff line change @@ -84,6 +84,24 @@ def test_dump_strict
8484 assert_equal '"World"' , "World" . to_json ( strict : true )
8585 end
8686
87+ def test_not_frozen
88+ [
89+ [ [ ] , '[]' ] ,
90+ [ { } , '{}' ] ,
91+ [ "string" , '"string"' ] ,
92+ [ :sym , '"sym"' ] ,
93+ [ 1 , '1' ] ,
94+ [ 1.0 , '1.0' ] ,
95+ [ true , 'true' ] ,
96+ [ false , 'false' ] ,
97+ [ nil , 'null' ] ,
98+ ] . each do |( obj , exp ) |
99+ dumped = dump ( obj , strict : true )
100+ assert_equal exp , dumped
101+ refute_predicate dumped , :frozen?
102+ end
103+ end
104+
87105 def test_state_depth_to_json
88106 depth = Object . new
89107 def depth . to_json ( state )
You can’t perform that action at this time.
0 commit comments