Skip to content

Commit afe5f77

Browse files
eregonmatzbot
authored andcommitted
[ruby/json] Keep Integer#to_json optimized and adapt the test
* Redefining Integer#to_s is bound to break many things, any non-segfault outcome should be acceptable. So adapt the test to just ensure it does not segfault. * Also redefining Kernel#String would also break with the previous code. ruby/json@ac0670b20b
1 parent 4a08bb7 commit afe5f77

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/json/json_generator_test.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,14 @@ def to_s
504504
end
505505
alias_method :to_s, :to_s
506506
end
507-
case RUBY_PLATFORM
508-
when "java"
507+
case RUBY_ENGINE
508+
when "jruby"
509509
assert_equal bignum_to_s, JSON.generate(bignum)
510-
else
510+
when "truffleruby"
511+
assert_raise(NoMethodError) do
512+
JSON.generate(bignum)
513+
end
514+
when "ruby"
511515
assert_raise(TypeError) do
512516
JSON.generate(bignum)
513517
end

0 commit comments

Comments
 (0)