ruby-changes:42798
From: akr <ko1@a...>
Date: Sun, 1 May 2016 23:19:41 +0900 (JST)
Subject: [ruby-changes:42798] akr:r54872 (trunk): envutil.rb defines Integer::{FIXNUM_MIN, FIXNUM_MAX}.
akr 2016-05-02 00:16:17 +0900 (Mon, 02 May 2016) New Revision: 54872 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54872 Log: envutil.rb defines Integer::{FIXNUM_MIN,FIXNUM_MAX}. * test/lib/envutil.rb: Define Integer::{FIXNUM_MIN,FIXNUM_MAX}. * test/ruby/test_bignum.rb: Use Integer::{FIXNUM_MIN,FIXNUM_MAX}. * test/ruby/test_bignum.rb: Ditto. * test/ruby/test_integer_comb.rb: Ditto. * test/ruby/test_marshal.rb: Ditto. * test/ruby/test_optimization.rb: Ditto. Modified files: trunk/ChangeLog trunk/test/lib/envutil.rb trunk/test/ruby/test_bignum.rb trunk/test/ruby/test_enum.rb trunk/test/ruby/test_integer_comb.rb trunk/test/ruby/test_marshal.rb trunk/test/ruby/test_optimization.rb Index: test/ruby/test_optimization.rb =================================================================== --- test/ruby/test_optimization.rb (revision 54871) +++ test/ruby/test_optimization.rb (revision 54872) @@ -3,20 +3,8 @@ require 'test/unit' https://github.com/ruby/ruby/blob/trunk/test/ruby/test_optimization.rb#L3 require 'objspace' class TestRubyOptimization < Test::Unit::TestCase - - BIGNUM_POS_MIN_32 = 1073741824 # 2 ** 30 - if BIGNUM_POS_MIN_32.kind_of?(Fixnum) - FIXNUM_MAX = 4611686018427387903 # 2 ** 62 - 1 - else - FIXNUM_MAX = 1073741823 # 2 ** 30 - 1 - end - - BIGNUM_NEG_MAX_32 = -1073741825 # -2 ** 30 - 1 - if BIGNUM_NEG_MAX_32.kind_of?(Fixnum) - FIXNUM_MIN = -4611686018427387904 # -2 ** 62 - else - FIXNUM_MIN = -1073741824 # -2 ** 30 - end + FIXNUM_MAX = Integer::FIXNUM_MAX + FIXNUM_MIN = Integer::FIXNUM_MIN def assert_redefine_method(klass, method, code, msg = nil) assert_separately([], <<-"end;")# do Index: test/ruby/test_enum.rb =================================================================== --- test/ruby/test_enum.rb (revision 54871) +++ test/ruby/test_enum.rb (revision 54872) @@ -2,7 +2,6 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enum.rb#L2 require 'test/unit' EnvUtil.suppress_warning {require 'continuation'} require 'stringio' -require "rbconfig/sizeof" class TestEnumerable < Test::Unit::TestCase def setup @@ -185,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 = -(1 << (8 * RbConfig::SIZEOF['long'] - 2)) - FIXNUM_MAX = (1 << (8 * RbConfig::SIZEOF['long'] - 2)) - 1 + FIXNUM_MIN = Integer::FIXNUM_MIN + FIXNUM_MAX = Integer::FIXNUM_MAX def test_inject_array_mul assert_equal(nil, [].inject(:*)) Index: test/ruby/test_integer_comb.rb =================================================================== --- test/ruby/test_integer_comb.rb (revision 54871) +++ test/ruby/test_integer_comb.rb (revision 54872) @@ -110,12 +110,8 @@ class TestIntegerComb < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_integer_comb.rb#L110 #VS.concat VS.find_all {|v| Fixnum === v }.map {|v| 0x4000000000000000.coerce(v)[0] } #VS.sort! {|a, b| a.abs <=> b.abs } - min = -1 - min *= 2 while min.class == Fixnum - FIXNUM_MIN = min/2 - max = 1 - max *= 2 while (max-1).class == Fixnum - FIXNUM_MAX = max/2-1 + FIXNUM_MIN = Integer::FIXNUM_MIN + FIXNUM_MAX = Integer::FIXNUM_MAX def test_fixnum_range assert_instance_of(Bignum, FIXNUM_MIN-1) Index: test/ruby/test_bignum.rb =================================================================== --- test/ruby/test_bignum.rb (revision 54871) +++ test/ruby/test_bignum.rb (revision 54872) @@ -2,16 +2,13 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_bignum.rb#L2 require 'test/unit' class TestBignum < Test::Unit::TestCase - b = 2**64 - b *= b until Bignum === b + FIXNUM_MIN = Integer::FIXNUM_MIN + FIXNUM_MAX = Integer::FIXNUM_MAX - f = b - while Bignum === f-1 - f >>= 1 - end - BIGNUM_MIN = f - FIXNUM_MAX = f-1 + BIGNUM_MIN = FIXNUM_MAX + 1 + b = BIGNUM_MIN + f = BIGNUM_MIN n = 0 until f == 0 f >>= 1 Index: test/ruby/test_marshal.rb =================================================================== --- test/ruby/test_marshal.rb (revision 54871) +++ test/ruby/test_marshal.rb (revision 54872) @@ -622,8 +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 = 1 << 32 - b *= b until Bignum === b + b = Integer::FIXNUM_MAX + 1 tainted = [0, 1.0, 1.72723e-77, b].select do |x| Marshal.load(Marshal.dump(x).taint).tainted? end Index: test/lib/envutil.rb =================================================================== --- test/lib/envutil.rb (revision 54871) +++ test/lib/envutil.rb (revision 54872) @@ -3,6 +3,12 @@ https://github.com/ruby/ruby/blob/trunk/test/lib/envutil.rb#L3 require "open3" require "timeout" require_relative "find_executable" +require "rbconfig/sizeof" + +class Integer + FIXNUM_MIN = -(1 << (8 * RbConfig::SIZEOF['long'] - 2)) + FIXNUM_MAX = (1 << (8 * RbConfig::SIZEOF['long'] - 2)) - 1 +end module EnvUtil def rubybin Index: ChangeLog =================================================================== --- ChangeLog (revision 54871) +++ ChangeLog (revision 54872) @@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon May 2 00:06:04 2016 Tanaka Akira <akr@f...> + + * test/lib/envutil.rb: Define Integer::{FIXNUM_MIN,FIXNUM_MAX}. + + * test/ruby/test_bignum.rb: Use Integer::{FIXNUM_MIN,FIXNUM_MAX}. + + * test/ruby/test_bignum.rb: Ditto. + + * test/ruby/test_integer_comb.rb: Ditto. + + * test/ruby/test_marshal.rb: Ditto. + + * test/ruby/test_optimization.rb: Ditto. + Sun May 1 23:59:59 2016 Kenta Murata <mrkn@m...> * array.c (rb_ary_sum): fix for mathn -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/