From 449fbfd4d4ce47be227804c22214fed32a5b0124 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 --- 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 +- 19 files changed, 52 insertions(+), 61 deletions(-) (limited to 'test/ruby') 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 -- cgit v1.2.3