From 32c7c3c19aa7c9c3fda10a9520d29e244baeaa6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Fri, 28 Nov 2025 15:53:58 +0100 Subject: [PATCH] [ruby/json] Reproduce C ext behavior of ignoring mutated depth in arrays https://github.com/ruby/json/commit/e0257b9f82 --- test/json/json_generator_test.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb index ab3a6807d6..e623e05409 100755 --- a/test/json/json_generator_test.rb +++ b/test/json/json_generator_test.rb @@ -329,7 +329,6 @@ class JSONGeneratorTest < Test::Unit::TestCase "#{state.indent * state.depth}\"foo\":#{state.space}1#{state.object_nl}"\ "#{state.indent * (state.depth - 1)}}" end - indent = " " * 2 if RUBY_ENGINE != "ruby" assert_equal <<~JSON.chomp, JSON.pretty_generate([obj] * 2) [ { @@ -338,11 +337,14 @@ class JSONGeneratorTest < Test::Unit::TestCase { "foo": 1 } - #{indent}] + ] JSON state = JSON::State.new(object_nl: "\n", array_nl: "\n", space: " ", indent: " ") state.generate(obj) - assert_equal 1, state.depth + assert_equal 1, state.depth # FIXME + state.depth = 0 + state.generate([obj]) + assert_equal 0, state.depth end def test_depth