diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-17 06:53:48 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-17 06:53:48 +0000 |
commit | 0362ad83a7c1852d638915859ca56f49d39fb8ac (patch) | |
tree | bdf433b181c6d6e00bd33581136ab2970bc9509d /test/ruby/test_bignum.rb | |
parent | 314346ad7b7248421af13633ad1bdec704799afe (diff) | |
download | ruby-0362ad83a7c1852d638915859ca56f49d39fb8ac.tar.gz |
[Feature #12005] Unify Fixnum and Bignum into Integer
* [Feature #12005] Unify Fixnum and Bignum into Integer
* include/ruby/ruby.h (rb_class_of): Return rb_cInteger for fixnums.
* insns.def (INTEGER_REDEFINED_OP_FLAG): Unified from
FIXNUM_REDEFINED_OP_FLAG and BIGNUM_REDEFINED_OP_FLAG.
* vm_core.h: Ditto.
* vm_insnhelper.c (opt_eq_func): Use INTEGER_REDEFINED_OP_FLAG instead
of FIXNUM_REDEFINED_OP_FLAG.
* vm.c (vm_redefinition_check_flag): Use rb_cInteger instead of
rb_cFixnum and rb_cBignum.
(C): Use Integer instead of Fixnum and Bignum.
* numeric.c (fix_succ): Removed.
(Init_Numeric): Define Fixnum as Integer.
* bignum.c (bignew): Use rb_cInteger instead of Rb_cBignum.
(rb_int_coerce): replaced from rb_big_coerce and return fixnums
as-is.
(Init_Bignum): Define Bignum as Integer.
Don't define ===.
* error.c (builtin_class_name): Return "Integer" for fixnums.
* sprintf.c (ruby__sfvextra): Use rb_cInteger instead of rb_cFixnum.
* ext/-test-/testutil: New directory to test.
Currently it provides utilities for fixnum and bignum.
* ext/json/generator/generator.c: Define mInteger_to_json.
* lib/mathn.rb (Fixnum#/): Redefinition removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_bignum.rb')
-rw-r--r-- | test/ruby/test_bignum.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb index 762368fda4..39f47ac6bb 100644 --- a/test/ruby/test_bignum.rb +++ b/test/ruby/test_bignum.rb @@ -16,17 +16,17 @@ class TestBignum < Test::Unit::TestCase end BIGNUM_MIN_BITS = n - 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 + T_ZERO = 0.to_bignum + T_ONE = 1.to_bignum + T_MONE = (-1).to_bignum + T31 = (2**31).to_bignum # 2147483648 + T31P = (T31 - 1).to_bignum # 2147483647 + T32 = (2**32).to_bignum # 4294967296 + T32P = (T32 - 1).to_bignum # 4294967295 + T64 = (2**64).to_bignum # 18446744073709551616 + T64P = (T64 - 1).to_bignum # 18446744073709551615 + T1024 = (2**1024).to_bignum + T1024P = (T1024 - 1).to_bignum def setup @verbose = $VERBOSE @@ -656,7 +656,7 @@ class TestBignum < Test::Unit::TestCase end def test_too_big_to_s - if (big = 2**31-1).is_a?(Fixnum) + if (big = 2**31-1).fixnum? return end assert_raise_with_message(RangeError, /too big to convert/) {(1 << big).to_s} |