mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 09:04:05 +02:00
[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
This commit is contained in:
parent
565241f11f
commit
f9727c12cc
25 changed files with 159 additions and 146 deletions
|
@ -29,7 +29,7 @@ class TestRubyOptimization < Test::Unit::TestCase
|
|||
assert_bignum FIXNUM_MAX + 1
|
||||
|
||||
assert_equal 21, 10 + 11
|
||||
assert_redefine_method('Fixnum', '+', 'assert_equal 11, 10 + 11')
|
||||
assert_redefine_method('Integer', '+', 'assert_equal 11, 10 + 11')
|
||||
end
|
||||
|
||||
def test_fixnum_minus
|
||||
|
@ -38,22 +38,22 @@ class TestRubyOptimization < Test::Unit::TestCase
|
|||
assert_bignum FIXNUM_MIN - 1
|
||||
|
||||
assert_equal 5, 8 - 3
|
||||
assert_redefine_method('Fixnum', '-', 'assert_equal 3, 8 - 3')
|
||||
assert_redefine_method('Integer', '-', 'assert_equal 3, 8 - 3')
|
||||
end
|
||||
|
||||
def test_fixnum_mul
|
||||
assert_equal 15, 3 * 5
|
||||
assert_redefine_method('Fixnum', '*', 'assert_equal 5, 3 * 5')
|
||||
assert_redefine_method('Integer', '*', 'assert_equal 5, 3 * 5')
|
||||
end
|
||||
|
||||
def test_fixnum_div
|
||||
assert_equal 3, 15 / 5
|
||||
assert_redefine_method('Fixnum', '/', 'assert_equal 5, 15 / 5')
|
||||
assert_redefine_method('Integer', '/', 'assert_equal 5, 15 / 5')
|
||||
end
|
||||
|
||||
def test_fixnum_mod
|
||||
assert_equal 1, 8 % 7
|
||||
assert_redefine_method('Fixnum', '%', 'assert_equal 7, 8 % 7')
|
||||
assert_redefine_method('Integer', '%', 'assert_equal 7, 8 % 7')
|
||||
end
|
||||
|
||||
def test_float_plus
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue