@@ -99,18 +99,26 @@ def test_load_null
99
99
100
100
def test_dump
101
101
too_deep = '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'
102
- assert_equal too_deep , dump ( eval ( too_deep ) )
103
- assert_kind_of String , Marshal . dump ( eval ( too_deep ) )
104
- assert_raise ( ArgumentError ) { dump ( eval ( too_deep ) , 100 ) }
105
- assert_raise ( ArgumentError ) { Marshal . dump ( eval ( too_deep ) , 100 ) }
106
- assert_equal too_deep , dump ( eval ( too_deep ) , 101 )
107
- assert_kind_of String , Marshal . dump ( eval ( too_deep ) , 101 )
108
- output = StringIO . new
109
- dump ( eval ( too_deep ) , output )
110
- assert_equal too_deep , output . string
111
- output = StringIO . new
112
- dump ( eval ( too_deep ) , output , 101 )
113
- assert_equal too_deep , output . string
102
+ obj = eval ( too_deep )
103
+ assert_equal too_deep , dump ( obj )
104
+ assert_kind_of String , Marshal . dump ( obj )
105
+ assert_raise ( ArgumentError ) { dump ( obj , 100 ) }
106
+ assert_raise ( ArgumentError ) { Marshal . dump ( obj , 100 ) }
107
+ assert_equal too_deep , dump ( obj , 101 )
108
+ assert_kind_of String , Marshal . dump ( obj , 101 )
109
+
110
+ assert_equal too_deep , JSON . dump ( obj , StringIO . new , 101 , strict : false ) . string
111
+ assert_equal too_deep , dump ( obj , StringIO . new , 101 , strict : false ) . string
112
+ assert_raise ( JSON ::GeneratorError ) { JSON . dump ( Object . new , StringIO . new , 101 , strict : true ) . string }
113
+ assert_raise ( JSON ::GeneratorError ) { dump ( Object . new , StringIO . new , 101 , strict : true ) . string }
114
+
115
+ assert_equal too_deep , dump ( obj , nil , nil , strict : false )
116
+ assert_equal too_deep , dump ( obj , nil , 101 , strict : false )
117
+ assert_equal too_deep , dump ( obj , StringIO . new , nil , strict : false ) . string
118
+ assert_equal too_deep , dump ( obj , nil , strict : false )
119
+ assert_equal too_deep , dump ( obj , 101 , strict : false )
120
+ assert_equal too_deep , dump ( obj , StringIO . new , strict : false ) . string
121
+ assert_equal too_deep , dump ( obj , strict : false )
114
122
end
115
123
116
124
def test_dump_should_modify_defaults
0 commit comments