ruby-changes:45684
From: nobu <ko1@a...>
Date: Thu, 2 Mar 2017 13:54:25 +0900 (JST)
Subject: [ruby-changes:45684] nobu:r57757 (trunk): test: use RbConfig::Limits
nobu 2017-03-02 13:54:19 +0900 (Thu, 02 Mar 2017) New Revision: 57757 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57757 Log: test: use RbConfig::Limits * test/lib/envutil.rb: rbconfig/sizeof may not be available when cross-compiling. use RbConfig::Limits instead of calculating limits of Fixnum with hard-coded CHAR_BIT. Modified files: trunk/test/-ext-/integer/test_integer.rb trunk/test/lib/envutil.rb trunk/test/ruby/test_array.rb trunk/test/ruby/test_bignum.rb trunk/test/ruby/test_enum.rb trunk/test/ruby/test_marshal.rb trunk/test/ruby/test_numeric.rb Index: test/ruby/test_array.rb =================================================================== --- test/ruby/test_array.rb (revision 57756) +++ test/ruby/test_array.rb (revision 57757) @@ -2759,8 +2759,8 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L2759 assert_raise(TypeError) {h.dig(1, 0)} end - FIXNUM_MIN = -(1 << (8 * RbConfig::SIZEOF['long'] - 2)) - FIXNUM_MAX = (1 << (8 * RbConfig::SIZEOF['long'] - 2)) - 1 + FIXNUM_MIN = RbConfig::Limits['FIXNUM_MIN'] + FIXNUM_MAX = RbConfig::Limits['FIXNUM_MAX'] def assert_typed_equal(e, v, cls, msg=nil) assert_kind_of(cls, v, msg) Index: test/ruby/test_bignum.rb =================================================================== --- test/ruby/test_bignum.rb (revision 57756) +++ test/ruby/test_bignum.rb (revision 57757) @@ -6,8 +6,8 @@ rescue LoadError https://github.com/ruby/ruby/blob/trunk/test/ruby/test_bignum.rb#L6 else class TestBignum < Test::Unit::TestCase - FIXNUM_MIN = Integer::FIXNUM_MIN - FIXNUM_MAX = Integer::FIXNUM_MAX + FIXNUM_MIN = RbConfig::Limits['FIXNUM_MIN'] + FIXNUM_MAX = RbConfig::Limits['FIXNUM_MAX'] BIGNUM_MIN = FIXNUM_MAX + 1 b = BIGNUM_MIN Index: test/ruby/test_enum.rb =================================================================== --- test/ruby/test_enum.rb (revision 57756) +++ test/ruby/test_enum.rb (revision 57757) @@ -184,8 +184,8 @@ class TestEnumerable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enum.rb#L184 assert_equal(nil, @empty.inject() {9}) end - FIXNUM_MIN = Integer::FIXNUM_MIN - FIXNUM_MAX = Integer::FIXNUM_MAX + FIXNUM_MIN = RbConfig::Limits['FIXNUM_MIN'] + FIXNUM_MAX = RbConfig::Limits['FIXNUM_MAX'] def test_inject_array_mul assert_equal(nil, [].inject(:*)) Index: test/ruby/test_marshal.rb =================================================================== --- test/ruby/test_marshal.rb (revision 57756) +++ test/ruby/test_marshal.rb (revision 57757) @@ -622,7 +622,7 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L622 def test_untainted_numeric bug8945 = '[ruby-core:57346] [Bug #8945] Numerics never be tainted' - b = Integer::FIXNUM_MAX + 1 + b = RbConfig::Limits['FIXNUM_MAX'] + 1 tainted = [0, 1.0, 1.72723e-77, b].select do |x| Marshal.load(Marshal.dump(x).taint).tainted? end Index: test/ruby/test_numeric.rb =================================================================== --- test/ruby/test_numeric.rb (revision 57756) +++ test/ruby/test_numeric.rb (revision 57757) @@ -258,7 +258,7 @@ class TestNumeric < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_numeric.rb#L258 end def test_step - bignum = Integer::FIXNUM_MAX + 1 + bignum = RbConfig::Limits['FIXNUM_MAX'] + 1 assert_raise(ArgumentError) { 1.step(10, 1, 0) { } } assert_raise(ArgumentError) { 1.step(10, 1, 0).size } assert_raise(ArgumentError) { 1.step(10, 0) { } } Index: test/-ext-/integer/test_integer.rb =================================================================== --- test/-ext-/integer/test_integer.rb (revision 57756) +++ test/-ext-/integer/test_integer.rb (revision 57757) @@ -3,8 +3,8 @@ require 'test/unit' https://github.com/ruby/ruby/blob/trunk/test/-ext-/integer/test_integer.rb#L3 require '-test-/integer' class TestInteger < Test::Unit::TestCase - FIXNUM_MIN = Integer::FIXNUM_MIN - FIXNUM_MAX = Integer::FIXNUM_MAX + FIXNUM_MIN = RbConfig::Limits['FIXNUM_MIN'] + FIXNUM_MAX = RbConfig::Limits['FIXNUM_MAX'] def test_fixnum_range assert_bignum(FIXNUM_MIN-1) Index: test/lib/envutil.rb =================================================================== --- test/lib/envutil.rb (revision 57756) +++ test/lib/envutil.rb (revision 57757) @@ -3,15 +3,13 @@ https://github.com/ruby/ruby/blob/trunk/test/lib/envutil.rb#L3 require "open3" require "timeout" require_relative "find_executable" -require "rbconfig/sizeof" begin require 'rbconfig' rescue LoadError end - -class Integer - FIXNUM_MIN = -(1 << (8 * RbConfig::SIZEOF['long'] - 2)) - FIXNUM_MAX = (1 << (8 * RbConfig::SIZEOF['long'] - 2)) - 1 +begin + require "rbconfig/sizeof" +rescue LoadError end module EnvUtil -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/