diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-27 07:10:49 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-27 07:10:49 +0000 |
commit | e344d8a48388a213e4dd404b128769c5dccbf11a (patch) | |
tree | 4118eb9266e6a6a9a1a5ea928dd0a2734ee73828 | |
parent | 1b4e1375374c37d092d069b887fca61e53701ad8 (diff) |
* test/ruby/test_bignum.rb: ensure constants to be Bignum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/ruby/test_bignum.rb | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb index bcd502a3dd..5458f0cf4a 100644 --- a/test/ruby/test_bignum.rb +++ b/test/ruby/test_bignum.rb @@ -108,18 +108,34 @@ class TestBignum < Test::Unit::TestCase assert_equal("-1777777777777777777777" ,-18446744073709551615.to_s(8)) end - - T_ZERO = (2**32).coerce(0).first - T_ONE = (2**32).coerce(1).first - T_MONE = (2**32).coerce(-1).first - T31 = 2**31 # 2147483648 - T31P = T31 - 1 # 2147483647 - T32 = 2**32 # 4294967296 - T32P = T32 - 1 # 4294967295 - T64 = 2**64 # 18446744073709551616 - T64P = T64 - 1 # 18446744073709551615 - T1024 = 2**1024 - T1024P = T1024 - 1 + b = 2**64 + b *= b until Bignum === b + + T_ZERO = b.coerce(0).first + T_ONE = b.coerce(1).first + T_MONE = b.coerce(-1).first + T31 = b.coerce(2**31).first # 2147483648 + T31P = b.coerce(T31 - 1).first # 2147483647 + T32 = b.coerce(2**32).first # 4294967296 + T32P = b.coerce(T32 - 1).first # 4294967295 + T64 = b.coerce(2**64).first # 18446744073709551616 + T64P = b.coerce(T64 - 1).first # 18446744073709551615 + T1024 = b.coerce(2**1024).first + T1024P = b.coerce(T1024 - 1).first + + def test_prepare + assert_instance_of(Bignum, T_ZERO) + assert_instance_of(Bignum, T_ONE) + assert_instance_of(Bignum, T_MONE) + assert_instance_of(Bignum, T31) + assert_instance_of(Bignum, T31P) + assert_instance_of(Bignum, T32) + assert_instance_of(Bignum, T32P) + assert_instance_of(Bignum, T64) + assert_instance_of(Bignum, T64P) + assert_instance_of(Bignum, T1024) + assert_instance_of(Bignum, T1024P) + end def test_big_2comp assert_equal("-4294967296", (~T32P).to_s) |