ruby-changes:42950
From: akr <ko1@a...>
Date: Tue, 17 May 2016 15:53:57 +0900 (JST)
Subject: [ruby-changes:42950] akr:r55024 (trunk): [Feature #12005] Unify Fixnum and Bignum into Integer
akr 2016-05-17 15:53:48 +0900 (Tue, 17 May 2016) New Revision: 55024 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55024 Log: [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. Modified files: trunk/ChangeLog trunk/bignum.c trunk/bootstraptest/test_literal.rb trunk/error.c trunk/ext/json/generator/generator.c trunk/ext/json/generator/generator.h trunk/include/ruby/ruby.h trunk/insns.def trunk/lib/mathn.rb trunk/numeric.c trunk/sprintf.c trunk/test/-ext-/num2int/test_num2int.rb trunk/test/-ext-/typeddata/test_typeddata.rb trunk/test/lib/test/unit/assertions.rb trunk/test/lib/test/unit.rb trunk/test/ruby/test_bignum.rb trunk/test/ruby/test_hash.rb trunk/test/ruby/test_integer.rb trunk/test/ruby/test_numeric.rb trunk/test/ruby/test_optimization.rb trunk/test/ruby/test_regexp.rb trunk/test/ruby/test_settracefunc.rb trunk/vm.c trunk/vm_core.h trunk/vm_insnhelper.c Index: sprintf.c =================================================================== --- sprintf.c (revision 55023) +++ sprintf.c (revision 55024) @@ -1349,8 +1349,8 @@ ruby__sfvextra(rb_printf_buffer *fp, siz https://github.com/ruby/ruby/blob/trunk/sprintf.c#L1349 if (value == rb_cNilClass) { return LITERAL("nil"); } - else if (value == rb_cFixnum) { - return LITERAL("Fixnum"); + else if (value == rb_cInteger) { + return LITERAL("Integer"); } else if (value == rb_cSymbol) { return LITERAL("Symbol"); Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 55023) +++ include/ruby/ruby.h (revision 55024) @@ -1936,7 +1936,7 @@ static inline VALUE https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1936 rb_class_of(VALUE obj) { if (RB_IMMEDIATE_P(obj)) { - if (RB_FIXNUM_P(obj)) return rb_cFixnum; + if (RB_FIXNUM_P(obj)) return rb_cInteger; if (RB_FLONUM_P(obj)) return rb_cFloat; if (obj == RUBY_Qtrue) return rb_cTrueClass; if (RB_STATIC_SYM_P(obj)) return rb_cSymbol; Index: numeric.c =================================================================== --- numeric.c (revision 55023) +++ numeric.c (revision 55024) @@ -2948,13 +2948,6 @@ int_even_p(VALUE num) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2948 * (-1).succ #=> 0 */ -static VALUE -fix_succ(VALUE num) -{ - long i = FIX2LONG(num) + 1; - return LONG2NUM(i); -} - VALUE rb_int_succ(VALUE num) { @@ -4954,6 +4947,7 @@ Init_Numeric(void) https://github.com/ruby/ruby/blob/trunk/numeric.c#L4947 rb_define_method(rb_cInteger, "abs", int_abs, 0); rb_define_method(rb_cInteger, "magnitude", int_abs, 0); + rb_define_method(rb_cInteger, "===", int_equal, 1); rb_define_method(rb_cInteger, "==", int_equal, 1); rb_define_method(rb_cInteger, ">", int_gt, 1); rb_define_method(rb_cInteger, ">=", int_ge, 1); @@ -4972,22 +4966,8 @@ Init_Numeric(void) https://github.com/ruby/ruby/blob/trunk/numeric.c#L4966 rb_define_method(rb_cInteger, "size", int_size, 0); rb_define_method(rb_cInteger, "bit_length", rb_int_bit_length, 0); - rb_cFixnum = rb_define_class("Fixnum", rb_cInteger); - - rb_define_method(rb_cFixnum, "+", fix_plus, 1); - rb_define_method(rb_cFixnum, "-", fix_minus, 1); - rb_define_method(rb_cFixnum, "*", fix_mul, 1); - rb_define_method(rb_cFixnum, "/", fix_div, 1); - rb_define_method(rb_cFixnum, "%", fix_mod, 1); - - rb_define_method(rb_cFixnum, "==", fix_equal, 1); - rb_define_method(rb_cFixnum, "===", fix_equal, 1); - rb_define_method(rb_cFixnum, ">", fix_gt, 1); - rb_define_method(rb_cFixnum, ">=", fix_ge, 1); - rb_define_method(rb_cFixnum, "<", fix_lt, 1); - rb_define_method(rb_cFixnum, "<=", fix_le, 1); - - rb_define_method(rb_cFixnum, "succ", fix_succ, 0); + rb_cFixnum = rb_cInteger; + rb_define_const(rb_cObject, "Fixnum", rb_cInteger); rb_cFloat = rb_define_class("Float", rb_cNumeric); Index: lib/mathn.rb =================================================================== --- lib/mathn.rb (revision 55023) +++ lib/mathn.rb (revision 55024) @@ -55,27 +55,12 @@ unless defined?(Math.exp!) https://github.com/ruby/ruby/blob/trunk/lib/mathn.rb#L55 end ## -# When mathn is required, Fixnum's division is enhanced to +# When mathn is required, Integer's division is enhanced to # return more precise values from mathematical expressions. # # 2/3*3 # => 0 # require 'mathn' # 2/3*3 # => 2 - -class Fixnum - remove_method :/ - - ## - # +/+ defines the Rational division for Fixnum. - # - # 1/3 # => (1/3) - - alias / quo -end - -## -# When mathn is required Bignum's division is enhanced to -# return more precise values from mathematical expressions. # # (2**72) / ((2**70) * 3) # => 4/3 Index: vm.c =================================================================== --- vm.c (revision 55023) +++ vm.c (revision 55024) @@ -1388,12 +1388,11 @@ static st_table *vm_opt_method_table = 0 https://github.com/ruby/ruby/blob/trunk/vm.c#L1388 static int vm_redefinition_check_flag(VALUE klass) { - if (klass == rb_cFixnum) return FIXNUM_REDEFINED_OP_FLAG; + if (klass == rb_cInteger) return INTEGER_REDEFINED_OP_FLAG; if (klass == rb_cFloat) return FLOAT_REDEFINED_OP_FLAG; if (klass == rb_cString) return STRING_REDEFINED_OP_FLAG; if (klass == rb_cArray) return ARRAY_REDEFINED_OP_FLAG; if (klass == rb_cHash) return HASH_REDEFINED_OP_FLAG; - if (klass == rb_cBignum) return BIGNUM_REDEFINED_OP_FLAG; if (klass == rb_cSymbol) return SYMBOL_REDEFINED_OP_FLAG; if (klass == rb_cTime) return TIME_REDEFINED_OP_FLAG; if (klass == rb_cRegexp) return REGEXP_REDEFINED_OP_FLAG; @@ -1461,25 +1460,25 @@ vm_init_redefined_flag(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L1460 #define OP(mid_, bop_) (mid = id##mid_, bop = BOP_##bop_, ruby_vm_redefined_flag[bop] = 0) #define C(k) add_opt_method(rb_c##k, mid, bop) - OP(PLUS, PLUS), (C(Fixnum), C(Float), C(String), C(Array)); - OP(MINUS, MINUS), (C(Fixnum), C(Float)); - OP(MULT, MULT), (C(Fixnum), C(Float)); - OP(DIV, DIV), (C(Fixnum), C(Float)); - OP(MOD, MOD), (C(Fixnum), C(Float)); - OP(Eq, EQ), (C(Fixnum), C(Float), C(String)); - OP(Eqq, EQQ), (C(Fixnum), C(Bignum), C(Float), C(Symbol), C(String), + OP(PLUS, PLUS), (C(Integer), C(Float), C(String), C(Array)); + OP(MINUS, MINUS), (C(Integer), C(Float)); + OP(MULT, MULT), (C(Integer), C(Float)); + OP(DIV, DIV), (C(Integer), C(Float)); + OP(MOD, MOD), (C(Integer), C(Float)); + OP(Eq, EQ), (C(Integer), C(Float), C(String)); + OP(Eqq, EQQ), (C(Integer), C(Float), C(Symbol), C(String), C(NilClass), C(TrueClass), C(FalseClass)); - OP(LT, LT), (C(Fixnum), C(Float)); - OP(LE, LE), (C(Fixnum), C(Float)); - OP(GT, GT), (C(Fixnum), C(Float)); - OP(GE, GE), (C(Fixnum), C(Float)); + OP(LT, LT), (C(Integer), C(Float)); + OP(LE, LE), (C(Integer), C(Float)); + OP(GT, GT), (C(Integer), C(Float)); + OP(GE, GE), (C(Integer), C(Float)); OP(LTLT, LTLT), (C(String), C(Array)); OP(AREF, AREF), (C(Array), C(Hash)); OP(ASET, ASET), (C(Array), C(Hash)); OP(Length, LENGTH), (C(Array), C(String), C(Hash)); OP(Size, SIZE), (C(Array), C(String), C(Hash)); OP(EmptyP, EMPTY_P), (C(Array), C(String), C(Hash)); - OP(Succ, SUCC), (C(Fixnum), C(String), C(Time)); + OP(Succ, SUCC), (C(Integer), C(String), C(Time)); OP(EqTilde, MATCH), (C(Regexp), C(String)); OP(Freeze, FREEZE), (C(String)); OP(Max, MAX), (C(Array)); Index: ext/json/generator/generator.c =================================================================== --- ext/json/generator/generator.c (revision 55023) +++ ext/json/generator/generator.c (revision 55024) @@ -7,7 +7,7 @@ static ID i_encoding, i_encode; https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L7 #endif static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject, - mHash, mArray, mFixnum, mBignum, mFloat, mString, mString_Extend, + mHash, mArray, mInteger, mFixnum, mBignum, mFloat, mString, mString_Extend, mTrueClass, mFalseClass, mNilClass, eGeneratorError, eNestingError, CRegexp_MULTILINE, CJSON_SAFE_STATE_PROTOTYPE, i_SAFE_STATE_PROTOTYPE; @@ -347,6 +347,16 @@ static VALUE mArray_to_json(int argc, VA https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L347 * * Returns a JSON string representation for this Integer number. */ +static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(integer); +} + +/* + * call-seq: to_json(*) + * + * Returns a JSON string representation for this Integer number. + */ static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self) { GENERATE_JSON(fixnum); @@ -825,6 +835,14 @@ static void generate_json_bignum(FBuffer https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L835 fbuffer_append_str(buffer, tmp); } +static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + if (FIXNUM_P(obj)) + generate_json_fixnum(buffer, Vstate, state, obj); + else + generate_json_bignum(buffer, Vstate, state, obj); +} + static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) { double value = RFLOAT_VALUE(obj); @@ -858,9 +876,9 @@ static void generate_json(FBuffer *buffe https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L876 generate_json_false(buffer, Vstate, state, obj); } else if (obj == Qtrue) { generate_json_true(buffer, Vstate, state, obj); - } else if (klass == rb_cFixnum) { + } else if (FIXNUM_P(obj)) { generate_json_fixnum(buffer, Vstate, state, obj); - } else if (klass == rb_cBignum) { + } else if (RB_TYPE_P(obj, T_BIGNUM)) { generate_json_bignum(buffer, Vstate, state, obj); } else if (klass == rb_cFloat) { generate_json_float(buffer, Vstate, state, obj); @@ -1402,10 +1420,16 @@ void Init_generator(void) https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.c#L1420 rb_define_method(mHash, "to_json", mHash_to_json, -1); mArray = rb_define_module_under(mGeneratorMethods, "Array"); rb_define_method(mArray, "to_json", mArray_to_json, -1); - mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum"); - rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1); - mBignum = rb_define_module_under(mGeneratorMethods, "Bignum"); - rb_define_method(mBignum, "to_json", mBignum_to_json, -1); + if (rb_cInteger == rb_cFixnum) { + mInteger = rb_define_module_under(mGeneratorMethods, "Integer"); + rb_define_method(mInteger, "to_json", mInteger_to_json, -1); + } + else { + mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum"); + rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1); + mBignum = rb_define_module_under(mGeneratorMethods, "Bignum"); + rb_define_method(mBignum, "to_json", mBignum_to_json, -1); + } mFloat = rb_define_module_under(mGeneratorMethods, "Float"); rb_define_method(mFloat, "to_json", mFloat_to_json, -1); mString = rb_define_module_under(mGeneratorMethods, "String"); Index: ext/json/generator/generator.h =================================================================== --- ext/json/generator/generator.h (revision 55023) +++ ext/json/generator/generator.h (revision 55024) @@ -122,6 +122,7 @@ static void generate_json_string(FBuffer https://github.com/ruby/ruby/blob/trunk/ext/json/generator/generator.h#L122 static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); Index: bignum.c =================================================================== --- bignum.c (revision 55023) +++ bignum.c (revision 55024) @@ -110,7 +110,7 @@ STATIC_ASSERT(sizeof_long_and_sizeof_bdi https://github.com/ruby/ruby/blob/trunk/bignum.c#L110 #define BIGNUM_SET_NEGATIVE_SIGN(b) BIGNUM_SET_SIGN(b, 0) #define BIGNUM_SET_POSITIVE_SIGN(b) BIGNUM_SET_SIGN(b, 1) -#define bignew(len,sign) bignew_1(rb_cBignum,(len),(sign)) +#define bignew(len,sign) bignew_1(rb_cInteger,(len),(sign)) #define BDIGITS_ZERO(ptr, n) do { \ BDIGIT *bdigitz_zero_ptr = (ptr); \ @@ -6669,16 +6669,16 @@ rb_big_hash(VALUE x) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6669 */ static VALUE -rb_big_coerce(VALUE x, VALUE y) +rb_int_coerce(VALUE x, VALUE y) { - if (FIXNUM_P(y)) { - y = rb_int2big(FIX2LONG(y)); + if (FIXNUM_P(y) || RB_BIGNUM_TYPE_P(y)) { + return rb_assoc_new(y, x); } - else if (!RB_BIGNUM_TYPE_P(y)) { - rb_raise(rb_eTypeError, "can't coerce %"PRIsVALUE" to Bignum", - rb_obj_class(y)); + else { + x = rb_Float(x); + y = rb_Float(y); + return rb_assoc_new(y, x); } - return rb_assoc_new(y, x); } VALUE @@ -6783,15 +6783,13 @@ rb_big_even_p(VALUE num) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6783 void Init_Bignum(void) { - rb_cBignum = rb_define_class("Bignum", rb_cInteger); - - rb_define_method(rb_cBignum, "coerce", rb_big_coerce, 1); + rb_cBignum = rb_cInteger; + rb_define_const(rb_cObject, "Bignum", rb_cInteger); - rb_define_method(rb_cBignum, "===", rb_big_eq, 1); + rb_define_method(rb_cInteger, "coerce", rb_int_coerce, 1); #ifdef USE_GMP /* The version of loaded GMP. */ - rb_define_const(rb_cBignum, "GMP_VERSION", rb_sprintf("GMP %s", gmp_version)); rb_define_const(rb_cInteger, "GMP_VERSION", rb_sprintf("GMP %s", gmp_version)); #endif Index: error.c =================================================================== --- error.c (revision 55023) +++ error.c (revision 55024) @@ -525,7 +525,7 @@ builtin_class_name(VALUE x) https://github.com/ruby/ruby/blob/trunk/error.c#L525 etype = "nil"; } else if (FIXNUM_P(x)) { - etype = "Fixnum"; + etype = "Integer"; } else if (SYMBOL_P(x)) { etype = "Symbol"; Index: test/-ext-/num2int/test_num2int.rb =================================================================== --- test/-ext-/num2int/test_num2int.rb (revision 55023) +++ test/-ext-/num2int/test_num2int.rb (revision 55024) @@ -104,7 +104,7 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L104 end def assert_fix2i_success(type, num, result=num) - return if !num.kind_of?(Fixnum) + return if !num.fixnum? func = "FIX2#{type}".upcase assert_fix2i_success_internal(result.to_s, func, num) end @@ -116,7 +116,7 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L116 end def assert_fix2i_error(type, num) - return if !num.kind_of?(Fixnum) + return if !num.fixnum? func = "FIX2#{type}".upcase assert_num2i_error_internal(func, num) end Index: test/-ext-/typeddata/test_typeddata.rb =================================================================== --- test/-ext-/typeddata/test_typeddata.rb (revision 55023) +++ test/-ext-/typeddata/test_typeddata.rb (revision 55024) @@ -10,7 +10,7 @@ class Test_TypedData < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/-ext-/typeddata/test_typeddata.rb#L10 assert_raise_with_message(TypeError, "wrong argument type Symbol (expected typed_data)") {Bug::TypedData.check(:e)} - assert_raise_with_message(TypeError, "wrong argument type Fixnum (expected typed_data)") {Bug::TypedData.check(0)} + assert_raise_with_message(TypeError, "wrong argument type Integer (expected typed_data)") {Bug::TypedData.check(0)} assert_raise_with_message(TypeError, "wrong argument type String (expected typed_data)") {Bug::TypedData.check("a")} Index: test/ruby/test_settracefunc.rb =================================================================== --- test/ruby/test_settracefunc.rb (revision 55023) +++ test/ruby/test_settracefunc.rb (revision 55024) @@ -35,9 +35,9 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L35 events.shift) assert_equal(["line", 4, __method__, self.class], events.shift) - assert_equal(["c-call", 4, :+, Fixnum], + assert_equal(["c-call", 4, :+, Integer], events.shift) - assert_equal(["c-return", 4, :+, Fixnum], + assert_equal(["c-return", 4, :+, Integer], events.shift) assert_equal(["line", 5, __method__, self.class], events.shift) @@ -73,9 +73,9 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L73 events.shift) assert_equal(["line", 5, :add, self.class], events.shift) - assert_equal(["c-call", 5, :+, Fixnum], + assert_equal(["c-call", 5, :+, Integer], events.shift) - assert_equal(["c-return", 5, :+, Fixnum], + assert_equal(["c-return", 5, :+, Integer], events.shift) assert_equal(["return", 6, :add, self.class], events.shift) @@ -353,8 +353,8 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L353 ["c-return", 8, :new, Class], ["call", 4, :foo, ThreadTraceInnerClass], ["line", 5, :foo, ThreadTraceInnerClass], - ["c-call", 5, :+, Fixnum], - ["c-return", 5, :+, Fixnum], + ["c-call", 5, :+, Integer], + ["c-return", 5, :+, Integer], ["return", 6, :foo, ThreadTraceInnerClass], ["line", 9, __method__, self.class], ["c-call", 9, :set_trace_func, Thread]].each do |e| @@ -768,10 +768,10 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L768 # pp events # expected_events = [[:b_call, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil], - [:c_call, :times, Integer, Fixnum, nil], + [:c_call, :times, Integer, Integer, nil], [:b_call, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil], [:b_return, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, 3], - [:c_return, :times, Integer, Fixnum, 1], + [:c_return, :times, Integer, Integer, 1], [:call, :method_for_test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil], [:b_call, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil], [:b_return, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, 4], Index: test/ruby/test_numeric.rb =================================================================== --- test/ruby/test_numeric.rb (revision 55023) +++ test/ruby/test_numeric.rb (revision 55024) @@ -28,7 +28,7 @@ class TestNumeric < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_numeric.rb#L28 assert_raise_with_message(TypeError, /:"\\u3042"/) {1^:"\u{3042}"} bug10711 = '[ruby-core:67405] [Bug #10711]' - exp = "1.2 can't be coerced into Fixnum" + exp = "1.2 can't be coerced into Integer" assert_raise_with_message(TypeError, exp, bug10711) { 1 & 1.2 } end Index: test/ruby/test_bignum.rb =================================================================== --- test/ruby/test_bignum.rb (revision 55023) +++ test/ruby/test_bignum.rb (revision 55024) @@ -16,17 +16,17 @@ class TestBignum < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_bignum.rb#L16 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 - (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/