diff options
31 files changed, 76 insertions, 85 deletions
@@ -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 BDIGMAX = (1 << BITSPERDIG) - 1 def test_big2str_generic @@ -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 BDIGMAX = (1 << BITSPERDIG) - 1 def test_divrem_normal @@ -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 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 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 assert_equal(x.big_mul_normal(y), x.big_mul_balance(y)) end @@ -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 BDIGMAX = (1 << BITSPERDIG) - 1 def test_str2big_poweroftwo @@ -105,7 +105,7 @@ class TestCSV::DataConverters < TestCSV end # gives us proper number conversion - assert_equal( [String, String, Fixnum, 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], @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], @parser.shift.map { |field| field.class } ) end @@ -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(String, d.to_s) end @@ -286,7 +286,7 @@ EOT if defined?(JSON::Ext::Generator) def test_broken_bignum # [ruby-core:38867] pid = fork do - Bignum.class_eval do def to_s end end @@ -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 :==, true, [1] - assert @mock.kind_of?(Fixnum), "didn't mock :kind_of\?" assert @mock == 1, "didn't mock :==" end @@ -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") end def test_dup @@ -74,7 +74,7 @@ module REXMLTests assert_equal( expected, got.to_s ) when Instruction assert_equal( expected, got.content ) - when Fixnum assert_equal( exected.to_f, got ) when String # normalize values for comparison @@ -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([ 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) 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 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) a = @cls[ 1, 'cat', 1..1 ] assert_equal(@cls[ 99, 99, 99], a.map! { 99 } ) @@ -708,7 +708,7 @@ class TestBasicInstructions < Test::Unit::TestCase @ivar end end - class Fixnum; include M; end class Float; include M; end class Symbol; include M; end class FalseClass; include M; end @@ -602,7 +602,7 @@ class TestBignum < Test::Unit::TestCase end def test_interrupt_during_to_s - if defined?(Bignum::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) return # GMP doesn't support interrupt during an operation. end return unless Process.respond_to?(:kill) @@ -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 EOS end @@ -46,9 +46,9 @@ class TestClass < Test::Unit::TestCase assert_same(Class, c.class) assert_same(Object, c.superclass) - c = Class.new(Fixnum) assert_same(Class, c.class) - assert_same(Fixnum, c.superclass) end def test_00_new_basic @@ -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) h = {} h[Complex(0)] = 0 @@ -220,7 +220,7 @@ class TestEnumerable < Test::Unit::TestCase def test_inject_array_plus_redefined assert_separately([], <<-"end;") - class Fixnum 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 @@ -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] @@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) end def test_eval_and_define_method @@ -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} end def test_to_a_lines @@ -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_equal '1234', 1_2_3_4.inspect - assert_instance_of Fixnum, 1_2_3_4 assert_equal '18', 0x12.inspect - assert_instance_of Fixnum, 0x12 assert_raise(SyntaxError) { eval("0x") } assert_equal '15', 0o17.inspect - assert_instance_of Fixnum, 0o17 assert_raise(SyntaxError) { eval("0o") } assert_equal '5', 0b101.inspect - assert_instance_of Fixnum, 0b101 assert_raise(SyntaxError) { eval("0b") } assert_equal '123456789012345678901234567890', 123456789012345678901234567890.inspect - assert_instance_of Bignum, 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_equal __LINE__, __LINE__ end @@ -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 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 } 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 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 } end def test_rational_to_f @@ -1695,7 +1695,7 @@ class TestModule < Test::Unit::TestCase to_f / other end end - Fixnum.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 prepend M def /(other) quo(other) @@ -1722,7 +1722,7 @@ class TestModule < Test::Unit::TestCase assert_separately [], %{ module M end - class Fixnum prepend M end module M @@ -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) a, b = 1.coerce(2.0) assert_equal(Float, a.class) @@ -138,7 +138,7 @@ class TestRange < Test::Unit::TestCase end def test_hash - assert_kind_of(Fixnum, (0..1).hash) assert_equal((0..1).hash, (0..1).hash) assert_not_equal((0..1).hash, (0...1).hash) end @@ -42,7 +42,7 @@ class Rational_Test < Test::Unit::TestCase end def test_hash - assert_instance_of(Fixnum, Rational(1,2).hash) h = {} h[Rational(0)] = 0 @@ -228,20 +228,20 @@ class TestRefinement < Test::Unit::TestCase assert_equal("Foo#x", foo.x) end - module FixnumSlashExt - refine Fixnum 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(0, 1 / 2) end - module FixnumPlusExt - refine Fixnum 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(3, 1 + 2) end @@ -265,10 +265,10 @@ class TestRefinement < Test::Unit::TestCase end module RefineSameClass - REFINEMENT1 = refine(Fixnum) { def foo; return "foo" end } - REFINEMENT2 = refine(Fixnum) { 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 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)")) 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 def foo "c" end @@ -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] RubyVM.stat(stat = {}) assert_not_empty stat @@ -248,7 +248,7 @@ module TestStruct def test_hash klass = @Struct.new(:a) o = klass.new(1) - assert_kind_of(Fixnum, o.hash) end def test_eql @@ -36,7 +36,7 @@ class TestVariable < Test::Unit::TestCase end def test_variable - assert_instance_of(Fixnum, $$) # read-only variable assert_raise(NameError) do @@ -3080,7 +3080,7 @@ Did you mean 'Ruby'? end end - err = 'specification_version must be a Fixnum (did you mean version?)' assert_equal err, e.message end end @@ -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) end count end |