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
This commit is contained in:
akr 2016-05-17 13:15:57 +00:00
parent 3118d1e46a
commit 449fbfd4d4
43 changed files with 122 additions and 109 deletions

View File

@ -1,3 +1,26 @@
Tue May 17 22:11:41 2016 Tanaka Akira <akr@fsij.org>
* 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 <akr@fsij.org>
* [Feature #12005] Unify Fixnum and Bignum into Integer

View File

@ -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

View File

@ -109,7 +109,7 @@ assert_equal %q{foo}, %q{
}
}
assert_equal %q{1}, %q{
class Fixnum
class Integer
Const = 1
end
1.instance_eval %{

3
enum.c
View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 } )

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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