Project

General

Profile

Feature #10728 ยป fixnum-size-warning.patch

akr (Akira Tanaka), 01/10/2015 11:40 AM

View differences:

lib/rake/application.rb (working copy)
452 452
            "(default is number of CPU cores + 4)",
453 453
            lambda { |value|
454 454
              if value.nil? || value == ''
455
                value = FIXNUM_MAX
455
                value = 2**32
456 456
              elsif value =~ /^\d+$/
457 457
                value = value.to_i
458 458
              else
......
783 783
      backtrace.find { |str| str =~ re } || ''
784 784
    end
785 785

  
786
  private
787
    FIXNUM_MAX = (2**(0.size * 8 - 2) - 1) # :nodoc:
788

  
789 786
  end
790 787
end
numeric.c (working copy)
3671 3671
 *     1.size            #=> 4
3672 3672
 *     -1.size           #=> 4
3673 3673
 *     2147483647.size   #=> 4
3674
 *
3675
 *  This method will be changed in future.
3676
 *  Use RbConfig::SIZEOF['long'] instead:
3677
 *
3678
 *    require 'rbconfig/sizeof'
3679
 *    RbConfig::SIZEOF['long']  #=> 4
3680
 *
3674 3681
 */
3675 3682

  
3676 3683
static VALUE
3677 3684
fix_size(VALUE fix)
3678 3685
{
3686
    rb_warn("Use RbConfig::SIZEOF['long'] instead of Fixnum#size");
3679 3687
    return INT2FIX(sizeof(long));
3680 3688
}
3681 3689

  
test/ruby/test_enumerator.rb (working copy)
1 1
require 'test/unit'
2
require 'rbconfig/sizeof'
2 3

  
3 4
class TestEnumerator < Test::Unit::TestCase
4 5
  def setup
......
115 116

  
116 117
  def test_with_index_large_offset
117 118
    bug8010 = '[ruby-dev:47131] [Bug #8010]'
118
    s = 1 << (8*1.size-2)
119
    s = 1 << (8*RbConfig::SIZEOF['long']-2)
119 120
    assert_equal([[1,s],[2,s+1],[3,s+2]], @obj.to_enum(:foo, 1, 2, 3).with_index(s).to_a, bug8010)
120 121
    s <<= 1
121 122
    assert_equal([[1,s],[2,s+1],[3,s+2]], @obj.to_enum(:foo, 1, 2, 3).with_index(s).to_a, bug8010)