diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-30 10:12:18 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-30 10:12:18 +0000 |
commit | 8ad74296447f628fef2110516f5c332f8c0a31fe (patch) | |
tree | 5952761bd69f8b1c17462aca1bf582b040d13df2 /test | |
parent | f7015c968c19b198ad54c31e755e87385f8b65d3 (diff) | |
download | ruby-8ad74296447f628fef2110516f5c332f8c0a31fe.tar.gz |
make FIXNUM_MAX visible from Ruby
Because our tests now have several places where FIXNUM_MAX is needed,
we decided to provide it along with several other constants.
* template/limits.c.tmpl: new file, defining RbConfig::Limits
* ext/rbconfig/sizeof/depend (limits.c): rule to generate limits.c
* test/-ext-/num2int/test_num2int.rb: use RbConfig::Limits
* bootstraptest/test_insns.rb: ditto.
* .gitignore: ignore new generated file.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/-ext-/num2int/test_num2int.rb | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/test/-ext-/num2int/test_num2int.rb b/test/-ext-/num2int/test_num2int.rb index 8eedc50db1..0b12209134 100644 --- a/test/-ext-/num2int/test_num2int.rb +++ b/test/-ext-/num2int/test_num2int.rb @@ -2,33 +2,29 @@ require 'test/unit' require '-test-/num2int' require '-test-/integer' +require 'rbconfig/sizeof' class TestNum2int < Test::Unit::TestCase - SHRT_MIN = -32768 - SHRT_MAX = 32767 - USHRT_MAX = 65535 + l = RbConfig::Limits - INT_MIN = -2147483648 - INT_MAX = 2147483647 - UINT_MAX = 4294967295 + SHRT_MIN = l["SHRT_MIN"] + SHRT_MAX = l["SHRT_MAX"] + USHRT_MAX = l["USHRT_MAX"] - case [0].pack('L!').size - when 4 - LONG_MAX = 2147483647 - LONG_MIN = -2147483648 - ULONG_MAX = 4294967295 - when 8 - LONG_MAX = 9223372036854775807 - LONG_MIN = -9223372036854775808 - ULONG_MAX = 18446744073709551615 - end + INT_MIN = l["INT_MIN"] + INT_MAX = l["INT_MAX"] + UINT_MAX = l["UINT_MAX"] + + LONG_MAX = l["LONG_MAX"] + LONG_MIN = l["LONG_MIN"] + ULONG_MAX = l["ULONG_MAX"] - LLONG_MAX = 9223372036854775807 - LLONG_MIN = -9223372036854775808 - ULLONG_MAX = 18446744073709551615 + LLONG_MAX = l["LLONG_MAX"] + LLONG_MIN = l["LLONG_MIN"] + ULLONG_MAX = l["ULLONG_MAX"] - FIXNUM_MAX = LONG_MAX/2 - FIXNUM_MIN = LONG_MIN/2 + FIXNUM_MAX = l["FIXNUM_MAX"] + FIXNUM_MIN = l["FIXNUM_MIN"] def fix2big(n) 10000000000000000000000000000.coerce(n)[0] |