From eafe3982896faa093156ba5b4b9cfee5de1584c9 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 17 May 2016 13:15:57 +0000 Subject: Use Integer instead of Fixnum and Bignum. * object.c, numeric.c, enum.c, ext/-test-/bignum/mul.c, lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rexml/xpath_parser.rb, lib/rubygems/specification.rb, lib/uri/generic.rb, bootstraptest/test_eval.rb, basictest/test.rb, test/-ext-/bignum/test_big2str.rb, test/-ext-/bignum/test_div.rb, test/-ext-/bignum/test_mul.rb, test/-ext-/bignum/test_str2big.rb, test/csv/test_data_converters.rb, test/date/test_date.rb, test/json/test_json_generate.rb, test/minitest/test_minitest_mock.rb, test/openssl/test_cipher.rb, test/rexml/test_jaxen.rb, test/ruby/test_array.rb, test/ruby/test_basicinstructions.rb, test/ruby/test_bignum.rb, test/ruby/test_case.rb, test/ruby/test_class.rb, test/ruby/test_complex.rb, test/ruby/test_enum.rb, test/ruby/test_eval.rb, test/ruby/test_iseq.rb, test/ruby/test_literal.rb, test/ruby/test_math.rb, test/ruby/test_module.rb, test/ruby/test_numeric.rb, test/ruby/test_range.rb, test/ruby/test_rational.rb, test/ruby/test_refinement.rb, test/ruby/test_rubyvm.rb, test/ruby/test_struct.rb, test/ruby/test_variable.rb, test/rubygems/test_gem_specification.rb, test/thread/test_queue.rb: Use Integer instead of Fixnum and Bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 23 +++++++++++++++++++++++ basictest/test.rb | 2 +- bootstraptest/test_eval.rb | 2 +- enum.c | 3 +-- ext/-test-/bignum/mul.c | 4 ++-- lib/rexml/quickpath.rb | 4 ++-- lib/rexml/text.rb | 2 +- lib/rexml/xpath_parser.rb | 2 +- lib/rubygems/specification.rb | 4 ++-- lib/uri/generic.rb | 4 ++-- numeric.c | 16 ++++++++-------- object.c | 4 ++-- test/-ext-/bignum/test_big2str.rb | 4 ++-- test/-ext-/bignum/test_div.rb | 4 ++-- test/-ext-/bignum/test_mul.rb | 12 ++++++------ test/-ext-/bignum/test_str2big.rb | 4 ++-- test/csv/test_data_converters.rb | 6 +++--- test/date/test_date.rb | 2 +- test/json/test_json_generate.rb | 2 +- test/minitest/test_minitest_mock.rb | 4 ++-- test/openssl/test_cipher.rb | 4 ++-- test/rexml/test_jaxen.rb | 2 +- test/ruby/test_array.rb | 12 ++++++------ test/ruby/test_basicinstructions.rb | 2 +- test/ruby/test_bignum.rb | 4 ++-- test/ruby/test_case.rb | 2 +- test/ruby/test_class.rb | 4 ++-- test/ruby/test_complex.rb | 4 ++-- test/ruby/test_enum.rb | 11 +---------- test/ruby/test_eval.rb | 4 ++-- test/ruby/test_iseq.rb | 2 +- test/ruby/test_literal.rb | 14 +++++++------- test/ruby/test_math.rb | 10 +++++----- test/ruby/test_module.rb | 6 +++--- test/ruby/test_numeric.rb | 4 ++-- test/ruby/test_range.rb | 2 +- test/ruby/test_rational.rb | 2 +- test/ruby/test_refinement.rb | 24 ++++++++++++------------ test/ruby/test_rubyvm.rb | 2 +- test/ruby/test_struct.rb | 2 +- test/ruby/test_variable.rb | 2 +- test/rubygems/test_gem_specification.rb | 2 +- test/thread/test_queue.rb | 2 +- 43 files changed, 122 insertions(+), 109 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8e8c4fa83..2fabd765ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +Tue May 17 22:11:41 2016 Tanaka Akira + + * object.c, numeric.c, enum.c, ext/-test-/bignum/mul.c, + lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rexml/xpath_parser.rb, + lib/rubygems/specification.rb, lib/uri/generic.rb, + bootstraptest/test_eval.rb, basictest/test.rb, + test/-ext-/bignum/test_big2str.rb, test/-ext-/bignum/test_div.rb, + test/-ext-/bignum/test_mul.rb, test/-ext-/bignum/test_str2big.rb, + test/csv/test_data_converters.rb, test/date/test_date.rb, + test/json/test_json_generate.rb, test/minitest/test_minitest_mock.rb, + test/openssl/test_cipher.rb, test/rexml/test_jaxen.rb, + test/ruby/test_array.rb, test/ruby/test_basicinstructions.rb, + test/ruby/test_bignum.rb, test/ruby/test_case.rb, + test/ruby/test_class.rb, test/ruby/test_complex.rb, + test/ruby/test_enum.rb, test/ruby/test_eval.rb, + test/ruby/test_iseq.rb, test/ruby/test_literal.rb, + test/ruby/test_math.rb, test/ruby/test_module.rb, + test/ruby/test_numeric.rb, test/ruby/test_range.rb, + test/ruby/test_rational.rb, test/ruby/test_refinement.rb, + test/ruby/test_rubyvm.rb, test/ruby/test_struct.rb, + test/ruby/test_variable.rb, test/rubygems/test_gem_specification.rb, + test/thread/test_queue.rb: Use Integer instead of Fixnum and Bignum. + Tue May 17 15:26:10 2016 Tanaka Akira * [Feature #12005] Unify Fixnum and Bignum into Integer diff --git a/basictest/test.rb b/basictest/test.rb index 734525ce3b..0ba4503faa 100644 --- a/basictest/test.rb +++ b/basictest/test.rb @@ -2134,7 +2134,7 @@ test.bar = 47 test_ok(test.bar == 47) test_check "variable" -test_ok($$.instance_of?(Fixnum)) +test_ok($$.instance_of?(Integer)) # read-only variable begin diff --git a/bootstraptest/test_eval.rb b/bootstraptest/test_eval.rb index bf7478006d..8e90ac2728 100644 --- a/bootstraptest/test_eval.rb +++ b/bootstraptest/test_eval.rb @@ -109,7 +109,7 @@ assert_equal %q{foo}, %q{ } } assert_equal %q{1}, %q{ - class Fixnum + class Integer Const = 1 end 1.instance_eval %{ diff --git a/enum.c b/enum.c index 7ecf00e56b..bed8dd29da 100644 --- a/enum.c +++ b/enum.c @@ -657,8 +657,7 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op) id = SYM2ID(op); if (id == idPLUS) { if ((FIXNUM_P(v) || RB_TYPE_P(v, T_BIGNUM)) && - rb_method_basic_definition_p(rb_cFixnum, idPLUS) && - rb_method_basic_definition_p(rb_cBignum, idPLUS)) { + rb_method_basic_definition_p(rb_cInteger, idPLUS)) { n = 0; for (; i < RARRAY_LEN(ary); i++) { e = RARRAY_AREF(ary, i); diff --git a/ext/-test-/bignum/mul.c b/ext/-test-/bignum/mul.c index d34e98fabb..b922f34437 100644 --- a/ext/-test-/bignum/mul.c +++ b/ext/-test-/bignum/mul.c @@ -54,8 +54,8 @@ mul_gmp(VALUE x, VALUE y) void Init_mul(VALUE klass) { - rb_define_const(rb_cBignum, "SIZEOF_BDIGIT", INT2NUM(SIZEOF_BDIGIT)); - rb_define_const(rb_cBignum, "BITSPERDIG", INT2NUM(SIZEOF_BDIGIT * CHAR_BIT)); + rb_define_const(rb_cInteger, "SIZEOF_BDIGIT", INT2NUM(SIZEOF_BDIGIT)); + rb_define_const(rb_cInteger, "BITSPERDIG", INT2NUM(SIZEOF_BDIGIT * CHAR_BIT)); rb_define_method(rb_cInteger, "big_mul_normal", mul_normal, 1); rb_define_method(rb_cInteger, "big_sq_fast", sq_fast, 0); rb_define_method(rb_cInteger, "big_mul_balance", mul_balance, 1); diff --git a/lib/rexml/quickpath.rb b/lib/rexml/quickpath.rb index f3ad29a93a..5d6c77ca38 100644 --- a/lib/rexml/quickpath.rb +++ b/lib/rexml/quickpath.rb @@ -194,7 +194,7 @@ module REXML case res when true results << element - when Fixnum + when Integer results << element if Functions.pair[0] == res when String results << element @@ -230,7 +230,7 @@ module REXML case res when true results << element - when Fixnum + when Integer results << element if Functions.pair[0] == res end end diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb index b132bab8f4..9ea8ba9df3 100644 --- a/lib/rexml/text.rb +++ b/lib/rexml/text.rb @@ -33,7 +33,7 @@ module REXML VALID_XML_CHARS = Regexp.new('^['+ VALID_CHAR.map { |item| case item - when Fixnum + when Integer [item].pack('U').force_encoding('utf-8') when Range [item.first, '-'.ord, item.last].pack('UUU').force_encoding('utf-8') diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb index edd1127735..181b2b6e85 100644 --- a/lib/rexml/xpath_parser.rb +++ b/lib/rexml/xpath_parser.rb @@ -17,7 +17,7 @@ class Symbol # to use across multiple Object types def dclone ; self ; end end -class Fixnum +class Integer # provides a unified +clone+ operation, for REXML::XPathParser # to use across multiple Object types def dclone ; self ; end diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index b3066f2003..c50ff31fdb 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -2696,9 +2696,9 @@ class Gem::Specification < Gem::BasicSpecification "#{full_name} contains itself (#{file_name}), check your files list" end - unless specification_version.is_a?(Fixnum) + unless specification_version.is_a?(Integer) raise Gem::InvalidSpecificationException, - 'specification_version must be a Fixnum (did you mean version?)' + 'specification_version must be a Integer (did you mean version?)' end case platform diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 3c4cb6e530..5e980d699e 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -683,7 +683,7 @@ module URI if @opaque raise InvalidURIError, "can not set port with registry or opaque" - elsif !v.kind_of?(Fixnum) && parser.regexp[:PORT] !~ v + elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v raise InvalidComponentError, "bad component(expected port component): #{v.inspect}" end @@ -697,7 +697,7 @@ module URI # see also URI::Generic.port= # def set_port(v) - v = v.empty? ? nil : v.to_i unless !v || v.kind_of?(Fixnum) + v = v.empty? ? nil : v.to_i unless !v || v.kind_of?(Integer) @port = v end protected :set_port diff --git a/numeric.c b/numeric.c index eee539e8e1..0ebaa95ecb 100644 --- a/numeric.c +++ b/numeric.c @@ -213,11 +213,11 @@ positive_int_p(VALUE num) const ID mid = '>'; if (FIXNUM_P(num)) { - if (method_basic_p(rb_cFixnum)) + if (method_basic_p(rb_cInteger)) return FIXNUM_POSITIVE_P(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { - if (method_basic_p(rb_cBignum)) + if (method_basic_p(rb_cInteger)) return BIGNUM_POSITIVE_P(num); } return RTEST(compare_with_zero(num, mid)); @@ -229,11 +229,11 @@ negative_int_p(VALUE num) const ID mid = '<'; if (FIXNUM_P(num)) { - if (method_basic_p(rb_cFixnum)) + if (method_basic_p(rb_cInteger)) return FIXNUM_NEGATIVE_P(num); } else if (RB_TYPE_P(num, T_BIGNUM)) { - if (method_basic_p(rb_cBignum)) + if (method_basic_p(rb_cInteger)) return BIGNUM_NEGATIVE_P(num); } return RTEST(compare_with_zero(num, mid)); @@ -706,11 +706,11 @@ num_positive_p(VALUE num) const ID mid = '>'; if (FIXNUM_P(num)) { - if (method_basic_p(rb_cFixnum)) + if (method_basic_p(rb_cInteger)) return (SIGNED_VALUE)num > (SIGNED_VALUE)INT2FIX(0) ? Qtrue : Qfalse; } else if (RB_TYPE_P(num, T_BIGNUM)) { - if (method_basic_p(rb_cBignum)) + if (method_basic_p(rb_cInteger)) return BIGNUM_POSITIVE_P(num) && !rb_bigzero_p(num) ? Qtrue : Qfalse; } return compare_with_zero(num, mid); @@ -2317,11 +2317,11 @@ num_step_negative_p(VALUE num) VALUE r; if (FIXNUM_P(num)) { - if (method_basic_p(rb_cFixnum)) + if (method_basic_p(rb_cInteger)) return (SIGNED_VALUE)num < 0; } else if (RB_TYPE_P(num, T_BIGNUM)) { - if (method_basic_p(rb_cBignum)) + if (method_basic_p(rb_cInteger)) return BIGNUM_NEGATIVE_P(num); } r = rb_rescue(num_step_compare_with_zero, num, coerce_rescue_quiet, Qnil); diff --git a/object.c b/object.c index 90d0fbf8a3..cc674b1584 100644 --- a/object.c +++ b/object.c @@ -2997,7 +2997,7 @@ rb_num_to_dbl(VALUE val) { if (SPECIAL_CONST_P(val)) { if (FIXNUM_P(val)) { - if (basic_to_f_p(rb_cFixnum)) + if (basic_to_f_p(rb_cInteger)) return fix2dbl_without_to_f(val); } else if (FLONUM_P(val)) { @@ -3012,7 +3012,7 @@ rb_num_to_dbl(VALUE val) case T_FLOAT: return rb_float_noflonum_value(val); case T_BIGNUM: - if (basic_to_f_p(rb_cBignum)) + if (basic_to_f_p(rb_cInteger)) return big2dbl_without_to_f(val); break; case T_RATIONAL: diff --git a/test/-ext-/bignum/test_big2str.rb b/test/-ext-/bignum/test_big2str.rb index 4fae24eb34..296a5a9c49 100644 --- a/test/-ext-/bignum/test_big2str.rb +++ b/test/-ext-/bignum/test_big2str.rb @@ -5,8 +5,8 @@ require "-test-/bignum" class TestBignum < Test::Unit::TestCase class TestBig2str < Test::Unit::TestCase - SIZEOF_BDIGIT = Bignum::SIZEOF_BDIGIT - BITSPERDIG = Bignum::BITSPERDIG + SIZEOF_BDIGIT = Integer::SIZEOF_BDIGIT + BITSPERDIG = Integer::BITSPERDIG BDIGMAX = (1 << BITSPERDIG) - 1 def test_big2str_generic diff --git a/test/-ext-/bignum/test_div.rb b/test/-ext-/bignum/test_div.rb index 9a8e93b081..c53332630a 100644 --- a/test/-ext-/bignum/test_div.rb +++ b/test/-ext-/bignum/test_div.rb @@ -5,8 +5,8 @@ require "-test-/bignum" class TestBignum < Test::Unit::TestCase class TestDiv < Test::Unit::TestCase - SIZEOF_BDIGIT = Bignum::SIZEOF_BDIGIT - BITSPERDIG = Bignum::BITSPERDIG + SIZEOF_BDIGIT = Integer::SIZEOF_BDIGIT + BITSPERDIG = Integer::BITSPERDIG BDIGMAX = (1 << BITSPERDIG) - 1 def test_divrem_normal diff --git a/test/-ext-/bignum/test_mul.rb b/test/-ext-/bignum/test_mul.rb index 103a00fbad..fa974ab55d 100644 --- a/test/-ext-/bignum/test_mul.rb +++ b/test/-ext-/bignum/test_mul.rb @@ -5,8 +5,8 @@ require "-test-/bignum" class TestBignum < Test::Unit::TestCase class TestMul < Test::Unit::TestCase - SIZEOF_BDIGIT = Bignum::SIZEOF_BDIGIT - BITSPERDIG = Bignum::BITSPERDIG + SIZEOF_BDIGIT = Integer::SIZEOF_BDIGIT + BITSPERDIG = Integer::BITSPERDIG BDIGMAX = (1 << BITSPERDIG) - 1 def test_mul_normal @@ -61,14 +61,14 @@ class TestBignum < Test::Unit::TestCase end def test_mul_balance_2x16 - x = (1 << Bignum::BITSPERDIG) | 1 - y = (1 << Bignum::BITSPERDIG*16) | 1 + x = (1 << Integer::BITSPERDIG) | 1 + y = (1 << Integer::BITSPERDIG*16) | 1 assert_equal(x.big_mul_normal(y), x.big_mul_balance(y)) end def test_mul_balance_2x17 - x = (1 << Bignum::BITSPERDIG) | 1 - y = (1 << Bignum::BITSPERDIG*17) | 1 + x = (1 << Integer::BITSPERDIG) | 1 + y = (1 << Integer::BITSPERDIG*17) | 1 assert_equal(x.big_mul_normal(y), x.big_mul_balance(y)) end diff --git a/test/-ext-/bignum/test_str2big.rb b/test/-ext-/bignum/test_str2big.rb index 3b5750154e..c14811d9c4 100644 --- a/test/-ext-/bignum/test_str2big.rb +++ b/test/-ext-/bignum/test_str2big.rb @@ -5,8 +5,8 @@ require "-test-/bignum" class TestBignum < Test::Unit::TestCase class TestStr2big < Test::Unit::TestCase - SIZEOF_BDIGIT = Bignum::SIZEOF_BDIGIT - BITSPERDIG = Bignum::BITSPERDIG + SIZEOF_BDIGIT = Integer::SIZEOF_BDIGIT + BITSPERDIG = Integer::BITSPERDIG BDIGMAX = (1 << BITSPERDIG) - 1 def test_str2big_poweroftwo diff --git a/test/csv/test_data_converters.rb b/test/csv/test_data_converters.rb index 70f996360c..e274b2b10b 100755 --- a/test/csv/test_data_converters.rb +++ b/test/csv/test_data_converters.rb @@ -105,7 +105,7 @@ class TestCSV::DataConverters < TestCSV end # gives us proper number conversion - assert_equal( [String, String, Fixnum, String, Float], + assert_equal( [String, String, Integer, String, Float], @parser.shift.map { |field| field.class } ) end @@ -114,7 +114,7 @@ class TestCSV::DataConverters < TestCSV assert_nothing_raised(Exception) { @parser.convert(:numeric) } # and use - assert_equal( [String, String, Fixnum, String, Float], + assert_equal( [String, String, Integer, String, Float], @parser.shift.map { |field| field.class } ) end @@ -125,7 +125,7 @@ class TestCSV::DataConverters < TestCSV assert_nothing_raised(Exception) { @parser.convert(:all) } # and use - assert_equal( [String, String, Fixnum, String, Float, DateTime], + assert_equal( [String, String, Integer, String, Float, DateTime], @parser.shift.map { |field| field.class } ) end diff --git a/test/date/test_date.rb b/test/date/test_date.rb index 3bb1f4a4c7..247cce1eaf 100644 --- a/test/date/test_date.rb +++ b/test/date/test_date.rb @@ -135,7 +135,7 @@ class TestDate < Test::Unit::TestCase d = Date.new d.freeze assert_equal(true, d.frozen?) - assert_instance_of(Fixnum, d.yday) + assert_instance_of(Integer, d.yday) assert_instance_of(String, d.to_s) end diff --git a/test/json/test_json_generate.rb b/test/json/test_json_generate.rb index 50895f6247..e5ae3f4987 100644 --- a/test/json/test_json_generate.rb +++ b/test/json/test_json_generate.rb @@ -286,7 +286,7 @@ EOT if defined?(JSON::Ext::Generator) def test_broken_bignum # [ruby-core:38867] pid = fork do - Bignum.class_eval do + Integer.class_eval do def to_s end end diff --git a/test/minitest/test_minitest_mock.rb b/test/minitest/test_minitest_mock.rb index 0db972674c..6dcf39b75e 100644 --- a/test/minitest/test_minitest_mock.rb +++ b/test/minitest/test_minitest_mock.rb @@ -132,10 +132,10 @@ class TestMiniTestMock < MiniTest::Unit::TestCase end def test_mock_is_a_blank_slate - @mock.expect :kind_of?, true, [Fixnum] + @mock.expect :kind_of?, true, [Integer] @mock.expect :==, true, [1] - assert @mock.kind_of?(Fixnum), "didn't mock :kind_of\?" + assert @mock.kind_of?(Integer), "didn't mock :kind_of\?" assert @mock == 1, "didn't mock :==" end diff --git a/test/openssl/test_cipher.rb b/test/openssl/test_cipher.rb index dae069e43c..32f0d118f4 100644 --- a/test/openssl/test_cipher.rb +++ b/test/openssl/test_cipher.rb @@ -53,8 +53,8 @@ class OpenSSL::TestCipher < Test::Unit::TestCase def test_info assert_equal("DES-EDE3-CBC", @c1.name, "name") assert_equal("DES-EDE3-CBC", @c2.name, "name") - assert_kind_of(Fixnum, @c1.key_len, "key_len") - assert_kind_of(Fixnum, @c1.iv_len, "iv_len") + assert_kind_of(Integer, @c1.key_len, "key_len") + assert_kind_of(Integer, @c1.iv_len, "iv_len") end def test_dup diff --git a/test/rexml/test_jaxen.rb b/test/rexml/test_jaxen.rb index aa9e2998ab..9cd7bee8c2 100644 --- a/test/rexml/test_jaxen.rb +++ b/test/rexml/test_jaxen.rb @@ -74,7 +74,7 @@ module REXMLTests assert_equal( expected, got.to_s ) when Instruction assert_equal( expected, got.content ) - when Fixnum + when Integer assert_equal( exected.to_f, got ) when String # normalize values for comparison diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 44eec9143d..ea6bdf097b 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -495,7 +495,7 @@ class TestArray < Test::Unit::TestCase def test_collect a = @cls[ 1, 'cat', 1..1 ] - assert_equal([ Fixnum, String, Range], a.collect {|e| e.class} ) + assert_equal([ Integer, String, Range], a.collect {|e| e.class} ) assert_equal([ 99, 99, 99], a.collect { 99 } ) assert_equal([], @cls[].collect { 99 }) @@ -509,8 +509,8 @@ class TestArray < Test::Unit::TestCase # also update map! def test_collect! a = @cls[ 1, 'cat', 1..1 ] - assert_equal([ Fixnum, String, Range], a.collect! {|e| e.class} ) - assert_equal([ Fixnum, String, Range], a) + assert_equal([ Integer, String, Range], a.collect! {|e| e.class} ) + assert_equal([ Integer, String, Range], a) a = @cls[ 1, 'cat', 1..1 ] assert_equal([ 99, 99, 99], a.collect! { 99 } ) @@ -588,7 +588,7 @@ class TestArray < Test::Unit::TestCase assert_in_out_err [], <<-EOS, ["[]", "0"], [], bug8654 ARY = Array.new(100) { |i| i } - class Fixnum + class Integer alias old_equal == def == other ARY.replace([]) if self.equal?(0) @@ -1074,8 +1074,8 @@ class TestArray < Test::Unit::TestCase # also update collect! def test_map! a = @cls[ 1, 'cat', 1..1 ] - assert_equal(@cls[ Fixnum, String, Range], a.map! {|e| e.class} ) - assert_equal(@cls[ Fixnum, String, Range], a) + assert_equal(@cls[ Integer, String, Range], a.map! {|e| e.class} ) + assert_equal(@cls[ Integer, String, Range], a) a = @cls[ 1, 'cat', 1..1 ] assert_equal(@cls[ 99, 99, 99], a.map! { 99 } ) diff --git a/test/ruby/test_basicinstructions.rb b/test/ruby/test_basicinstructions.rb index c0ce02648d..dd3ca4dd22 100644 --- a/test/ruby/test_basicinstructions.rb +++ b/test/ruby/test_basicinstructions.rb @@ -708,7 +708,7 @@ class TestBasicInstructions < Test::Unit::TestCase @ivar end end - class Fixnum; include M; end + class Integer; include M; end class Float; include M; end class Symbol; include M; end class FalseClass; include M; end diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb index 39f47ac6bb..d2d15f636b 100644 --- a/test/ruby/test_bignum.rb +++ b/test/ruby/test_bignum.rb @@ -602,7 +602,7 @@ class TestBignum < Test::Unit::TestCase end def test_interrupt_during_to_s - if defined?(Bignum::GMP_VERSION) + if defined?(Integer::GMP_VERSION) return # GMP doesn't support interrupt during an operation. end time = Time.now @@ -623,7 +623,7 @@ class TestBignum < Test::Unit::TestCase end def test_interrupt_during_bigdivrem - if defined?(Bignum::GMP_VERSION) + if defined?(Integer::GMP_VERSION) return # GMP doesn't support interrupt during an operation. end return unless Process.respond_to?(:kill) diff --git a/test/ruby/test_case.rb b/test/ruby/test_case.rb index 861fd8ea06..77612a8945 100644 --- a/test/ruby/test_case.rb +++ b/test/ruby/test_case.rb @@ -81,7 +81,7 @@ class TestCase < Test::Unit::TestCase EOS assert_in_out_err(['-e', <<-EOS], '', %w[42], []) - class Fixnum; undef ===; def ===(o); p 42; true; end; end; case 1; when 1; end + class Integer; undef ===; def ===(o); p 42; true; end; end; case 1; when 1; end EOS end diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 66a4059db7..072729d4e5 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -46,9 +46,9 @@ class TestClass < Test::Unit::TestCase assert_same(Class, c.class) assert_same(Object, c.superclass) - c = Class.new(Fixnum) + c = Class.new(Integer) assert_same(Class, c.class) - assert_same(Fixnum, c.superclass) + assert_same(Integer, c.superclass) end def test_00_new_basic diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index e51dec01cf..9063149484 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -48,8 +48,8 @@ class Complex_Test < Test::Unit::TestCase end def test_hash - assert_instance_of(Fixnum, Complex(1,2).hash) - assert_instance_of(Fixnum, Complex(1.0,2.0).hash) + assert_fixnum(Complex(1,2).hash) + assert_fixnum(Complex(1.0,2.0).hash) h = {} h[Complex(0)] = 0 diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index 4d4363cf0e..4951cd1b2b 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -220,7 +220,7 @@ class TestEnumerable < Test::Unit::TestCase def test_inject_array_plus_redefined assert_separately([], <<-"end;") - class Fixnum + class Integer undef :+ def +(x) 0 @@ -228,15 +228,6 @@ class TestEnumerable < Test::Unit::TestCase end assert_equal(0, [1,2,3].inject(:+), "[ruby-dev:49510] [Bug#12178]") end; - assert_separately([], <<-"end;") - class Bignum - undef :+ - def +(x) - 0 - end - end - assert_equal(0, [#{FIXNUM_MAX},1,1].inject(:+)) - end; end def test_partition diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb index 30f5e5ce9d..9108c236d6 100644 --- a/test/ruby/test_eval.rb +++ b/test/ruby/test_eval.rb @@ -402,10 +402,10 @@ class TestEval < Test::Unit::TestCase def test_cvar_scope_with_instance_eval # TODO: check - Fixnum.class_eval "@@test_cvar_scope_with_instance_eval = 1" # depends on [ruby-dev:24229] + Integer.class_eval "@@test_cvar_scope_with_instance_eval = 1" # depends on [ruby-dev:24229] @@test_cvar_scope_with_instance_eval = 4 assert_equal(4, 1.instance_eval("@@test_cvar_scope_with_instance_eval"), "[ruby-dev:24223]") - Fixnum.__send__(:remove_class_variable, :@@test_cvar_scope_with_instance_eval) + Integer.__send__(:remove_class_variable, :@@test_cvar_scope_with_instance_eval) end def test_eval_and_define_method diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index e0c5329edc..a71ad565f7 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -16,7 +16,7 @@ class TestISeq < Test::Unit::TestCase def lines src body = compile(src).to_a[13] - body.find_all{|e| e.kind_of? Fixnum} + body.find_all{|e| e.kind_of? Integer} end def test_to_a_lines diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index 522ca53ea4..c37b206539 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -14,20 +14,20 @@ class TestRubyLiteral < Test::Unit::TestCase assert_equal ':sym', :sym.inspect assert_instance_of Symbol, :sym assert_equal '1234', 1234.inspect - assert_instance_of Fixnum, 1234 + assert_instance_of Integer, 1234 assert_equal '1234', 1_2_3_4.inspect - assert_instance_of Fixnum, 1_2_3_4 + assert_instance_of Integer, 1_2_3_4 assert_equal '18', 0x12.inspect - assert_instance_of Fixnum, 0x12 + assert_instance_of Integer, 0x12 assert_raise(SyntaxError) { eval("0x") } assert_equal '15', 0o17.inspect - assert_instance_of Fixnum, 0o17 + assert_instance_of Integer, 0o17 assert_raise(SyntaxError) { eval("0o") } assert_equal '5', 0b101.inspect - assert_instance_of Fixnum, 0b101 + assert_instance_of Integer, 0b101 assert_raise(SyntaxError) { eval("0b") } assert_equal '123456789012345678901234567890', 123456789012345678901234567890.inspect - assert_instance_of Bignum, 123456789012345678901234567890 + assert_instance_of Integer, 123456789012345678901234567890 assert_instance_of Float, 1.3 assert_equal '2', eval("0x00+2").inspect end @@ -427,7 +427,7 @@ class TestRubyLiteral < Test::Unit::TestCase end def test__LINE__ - assert_instance_of Fixnum, __LINE__ + assert_instance_of Integer, __LINE__ assert_equal __LINE__, __LINE__ end diff --git a/test/ruby/test_math.rb b/test/ruby/test_math.rb index 1d571252ee..ac9ab3c961 100644 --- a/test/ruby/test_math.rb +++ b/test/ruby/test_math.rb @@ -286,8 +286,8 @@ class TestMath < Test::Unit::TestCase check(12.0, Math.sqrt(144)) end - def test_override_fixnum_to_f - Fixnum.class_eval do + def test_override_integer_to_f + Integer.class_eval do alias _to_f to_f def to_f (self + 1)._to_f @@ -298,7 +298,7 @@ class TestMath < Test::Unit::TestCase check(Math.exp((0 + 1)._to_f), Math.exp(0)) check(Math.log((0 + 1)._to_f), Math.log(0)) ensure - Fixnum.class_eval { undef to_f; alias to_f _to_f; undef _to_f } + Integer.class_eval { undef to_f; alias to_f _to_f; undef _to_f } end def test_bignum_to_f @@ -306,7 +306,7 @@ class TestMath < Test::Unit::TestCase end def test_override_bignum_to_f - Bignum.class_eval do + Integer.class_eval do alias _to_f to_f def to_f (self << 1)._to_f @@ -316,7 +316,7 @@ class TestMath < Test::Unit::TestCase check(Math.cos((1 << 64 << 1)._to_f), Math.cos(1 << 64)) check(Math.log((1 << 64 << 1)._to_f), Math.log(1 << 64)) ensure - Bignum.class_eval { undef to_f; alias to_f _to_f; undef _to_f } + Integer.class_eval { undef to_f; alias to_f _to_f; undef _to_f } end def test_rational_to_f diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 4ca79a7d5c..65e6a2c4c4 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1695,7 +1695,7 @@ class TestModule < Test::Unit::TestCase to_f / other end end - Fixnum.send(:prepend, M) + Integer.send(:prepend, M) assert_equal(0.5, 1 / 2, "#{bug7983}") } assert_equal(0, 1 / 2) @@ -1706,7 +1706,7 @@ class TestModule < Test::Unit::TestCase assert_separately [], %{ module M end - class Fixnum + class Integer prepend M def /(other) quo(other) @@ -1722,7 +1722,7 @@ class TestModule < Test::Unit::TestCase assert_separately [], %{ module M end - class Fixnum + class Integer prepend M end module M diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index c2a2e001b8..51d266f230 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -4,8 +4,8 @@ require 'test/unit' class TestNumeric < Test::Unit::TestCase def test_coerce a, b = 1.coerce(2) - assert_equal(Fixnum, a.class) - assert_equal(Fixnum, b.class) + assert_fixnum(a) + assert_fixnum(b) a, b = 1.coerce(2.0) assert_equal(Float, a.class) diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index 2fc2a2b1d3..2bff105936 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -138,7 +138,7 @@ class TestRange < Test::Unit::TestCase end def test_hash - assert_kind_of(Fixnum, (0..1).hash) + assert_fixnum((0..1).hash) assert_equal((0..1).hash, (0..1).hash) assert_not_equal((0..1).hash, (0...1).hash) end diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index 801a6fe872..a87eb863eb 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -42,7 +42,7 @@ class Rational_Test < Test::Unit::TestCase end def test_hash - assert_instance_of(Fixnum, Rational(1,2).hash) + assert_fixnum(Rational(1,2).hash) h = {} h[Rational(0)] = 0 diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 29c5f631f4..1984d2c2af 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -228,20 +228,20 @@ class TestRefinement < Test::Unit::TestCase assert_equal("Foo#x", foo.x) end - module FixnumSlashExt - refine Fixnum do + module IntegerSlashExt + refine Integer do def /(other) quo(other) end end end def test_override_builtin_method assert_equal(0, 1 / 2) - assert_equal(Rational(1, 2), eval_using(FixnumSlashExt, "1 / 2")) + assert_equal(Rational(1, 2), eval_using(IntegerSlashExt, "1 / 2")) assert_equal(0, 1 / 2) end - module FixnumPlusExt - refine Fixnum do + module IntegerPlusExt + refine Integer do def self.method_added(*args); end def +(other) "overridden" end end @@ -249,7 +249,7 @@ class TestRefinement < Test::Unit::TestCase def test_override_builtin_method_with_method_added assert_equal(3, 1 + 2) - assert_equal("overridden", eval_using(FixnumPlusExt, "1 + 2")) + assert_equal("overridden", eval_using(IntegerPlusExt, "1 + 2")) assert_equal(3, 1 + 2) end @@ -265,10 +265,10 @@ class TestRefinement < Test::Unit::TestCase end module RefineSameClass - REFINEMENT1 = refine(Fixnum) { + REFINEMENT1 = refine(Integer) { def foo; return "foo" end } - REFINEMENT2 = refine(Fixnum) { + REFINEMENT2 = refine(Integer) { def bar; return "bar" end } REFINEMENT3 = refine(String) { @@ -283,15 +283,15 @@ class TestRefinement < Test::Unit::TestCase assert_not_equal(RefineSameClass::REFINEMENT1, RefineSameClass::REFINEMENT3) end - module FixnumFooExt - refine Fixnum do + module IntegerFooExt + refine Integer do def foo; "foo"; end end end def test_respond_to_should_not_use_refinements assert_equal(false, 1.respond_to?(:foo)) - assert_equal(false, eval_using(FixnumFooExt, "1.respond_to?(:foo)")) + assert_equal(false, eval_using(IntegerFooExt, "1.respond_to?(:foo)")) end module StringCmpExt @@ -382,7 +382,7 @@ class TestRefinement < Test::Unit::TestCase def test_refine_in_class assert_raise(NoMethodError) do Class.new { - refine Fixnum do + refine Integer do def foo "c" end diff --git a/test/ruby/test_rubyvm.rb b/test/ruby/test_rubyvm.rb index c2d334d04c..7673d8dfbe 100644 --- a/test/ruby/test_rubyvm.rb +++ b/test/ruby/test_rubyvm.rb @@ -4,7 +4,7 @@ require 'test/unit' class TestRubyVM < Test::Unit::TestCase def test_stat assert_kind_of Hash, RubyVM.stat - assert_kind_of Fixnum, RubyVM.stat[:global_method_state] + assert_kind_of Integer, RubyVM.stat[:global_method_state] RubyVM.stat(stat = {}) assert_not_empty stat diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index 1223d4b816..86b7e3f0a7 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -248,7 +248,7 @@ module TestStruct def test_hash klass = @Struct.new(:a) o = klass.new(1) - assert_kind_of(Fixnum, o.hash) + assert_fixnum(o.hash) end def test_eql diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb index c8e2617df6..4606f725c3 100644 --- a/test/ruby/test_variable.rb +++ b/test/ruby/test_variable.rb @@ -36,7 +36,7 @@ class TestVariable < Test::Unit::TestCase end def test_variable - assert_instance_of(Fixnum, $$) + assert_instance_of(Integer, $$) # read-only variable assert_raise(NameError) do diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 8598e924ff..bbb9a7ebaa 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -3080,7 +3080,7 @@ Did you mean 'Ruby'? end end - err = 'specification_version must be a Fixnum (did you mean version?)' + err = 'specification_version must be a Integer (did you mean version?)' assert_equal err, e.message end end diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb index 32662babed..d2ab683c0c 100644 --- a/test/thread/test_queue.rb +++ b/test/thread/test_queue.rb @@ -509,7 +509,7 @@ class TestQueue < Test::Unit::TestCase count = 0 while e = q.pop i, st = e - count += 1 if i.is_a?(Fixnum) && st.is_a?(String) + count += 1 if i.is_a?(Integer) && st.is_a?(String) end count end -- cgit v1.2.3