From d71be7274bd2623bb521be72c245c08fc38d6ae4 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 6 Nov 2024 13:31:38 +0900 Subject: [Bug #20873] Consider `-FIXNUM_MIN` overflow `-FIXNUM_MIN` is usually greater than `FIXNUM_MAX` on platforms using two's complement representation. --- test/ruby/test_sprintf.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index 498f93aec4..3bd3bc793c 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -227,6 +227,10 @@ class TestSprintf < Test::Unit::TestCase bug11766 = '[ruby-core:71806] [Bug #11766]' assert_equal("x"*10+" 1.0", sprintf("x"*10+"%8.1f", 1r), bug11766) + + require 'rbconfig/sizeof' + fmin, fmax = RbConfig::LIMITS.values_at("FIXNUM_MIN", "FIXNUM_MAX") + assert_match(/\A-\d+\.\d+\z/, sprintf("%f", Rational(fmin, fmax))) end def test_rational_precision -- cgit v1.2.3