diff options
| author | Étienne Barrié <etienne.barrie@gmail.com> | 2025-11-23 11:36:58 +0100 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-11-26 14:47:27 +0000 |
| commit | fb642b78cb89dd26ade620bda16ca78b570a907e (patch) | |
| tree | 8c917e63ede19db59c5ef07247aa5b783f14ff8f | |
| parent | 38022961ae399015c542c409948aa4885e8e56e0 (diff) | |
[ruby/json] Test that depth of unfrozen State does not change
https://github.com/ruby/json/commit/9d32cf4618
| -rwxr-xr-x | test/json/json_generator_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb index 54a2ec6140..f1fb72ee29 100755 --- a/test/json/json_generator_test.rb +++ b/test/json/json_generator_test.rb @@ -915,4 +915,13 @@ class JSONGeneratorTest < Test::Unit::TestCase end end end + + # The case when the State is frozen is tested in JSONCoderTest#test_nesting_recovery + def test_nesting_recovery + state = JSON::State.new + ary = [] + ary << ary + assert_raise(JSON::NestingError) { state.generate_new(ary) } + assert_equal '{"a":1}', state.generate({ a: 1 }) + end end |
