Skip to content

Commit 9d32cf4

Browse files
etiennebarriebyroot
authored andcommitted
Test that depth of unfrozen State does not change
1 parent 4f4551f commit 9d32cf4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/json/json_generator_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,4 +915,13 @@ def test_frozen
915915
end
916916
end
917917
end
918+
919+
# The case when the State is frozen is tested in JSONCoderTest#test_nesting_recovery
920+
def test_nesting_recovery
921+
state = JSON::State.new
922+
ary = []
923+
ary << ary
924+
assert_raise(JSON::NestingError) { state.generate_new(ary) }
925+
assert_equal '{"a":1}', state.generate({ a: 1 })
926+
end
918927
end

0 commit comments

Comments
 (0)