summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-01 15:16:17 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-01 15:16:17 +0000
commitde2f7416d2deb4166d78638a41037cb550d64484 (patch)
tree2481ed6dd9955cdeae6ac3dd5220ba4c9261aaec /test/ruby
parentf98c9a0aa63c5db16005709eff807dcad525bf57 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_bignum.rb13
-rw-r--r--test/ruby/test_enum.rb5
-rw-r--r--test/ruby/test_integer_comb.rb8
-rw-r--r--test/ruby/test_marshal.rb3
-rw-r--r--test/ruby/test_optimization.rb16
5 files changed, 12 insertions, 33 deletions
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index b16832302e..f80828a7a1 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -2,16 +2,13 @@
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
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index 97730f919f..4d4363cf0e 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -2,7 +2,6 @@
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::TestCase
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(:*))
diff --git a/test/ruby/test_integer_comb.rb b/test/ruby/test_integer_comb.rb
index c96b34a477..b18de94feb 100644
--- a/test/ruby/test_integer_comb.rb
+++ b/test/ruby/test_integer_comb.rb
@@ -110,12 +110,8 @@ class TestIntegerComb < Test::Unit::TestCase
#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)
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index e2e321bb41..b723fcae3c 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -622,8 +622,7 @@ class TestMarshal < Test::Unit::TestCase
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
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index 605e0306fa..6412d1f45e 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -3,20 +3,8 @@ require 'test/unit'
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