Skip to content

Commit

Permalink
Use Integer instead of Fixnum and Bignum.
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
akr committed May 17, 2016
1 parent 3118d1e commit 449fbfd
Show file tree
Hide file tree
Showing 43 changed files with 122 additions and 109 deletions.
23 changes: 23 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
Tue May 17 22:11:41 2016 Tanaka Akira <[email protected]>

* 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 <[email protected]>

* [Feature #12005] Unify Fixnum and Bignum into Integer
Expand Down
2 changes: 1 addition & 1 deletion basictest/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ module M003; include M002; end
test_ok(test.bar == 47)

test_check "variable"
test_ok($$.instance_of?(Fixnum))
test_ok($$.instance_of?(Integer))

# read-only variable
begin
Expand Down
2 changes: 1 addition & 1 deletion bootstraptest/test_eval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def foo
}
}
assert_equal %q{1}, %q{
class Fixnum
class Integer
Const = 1
end
1.instance_eval %{
Expand Down
3 changes: 1 addition & 2 deletions enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions ext/-test-/bignum/mul.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/rexml/quickpath.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def QuickPath::predicate( elements, path )
case res
when true
results << element
when Fixnum
when Integer
results << element if Functions.pair[0] == res
when String
results << element
Expand Down Expand Up @@ -230,7 +230,7 @@ def QuickPath::function( elements, fname, rest )
case res
when true
results << element
when Fixnum
when Integer
results << element if Functions.pair[0] == res
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rexml/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Text < Child
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')
Expand Down
2 changes: 1 addition & 1 deletion lib/rexml/xpath_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/rubygems/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2696,9 +2696,9 @@ def validate packaging = true
"#{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
Expand Down
4 changes: 2 additions & 2 deletions lib/uri/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def check_port(v)
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
Expand All @@ -697,7 +697,7 @@ def check_port(v)
# 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
Expand Down
16 changes: 8 additions & 8 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions test/-ext-/bignum/test_big2str.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
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
Expand Down
4 changes: 2 additions & 2 deletions test/-ext-/bignum/test_div.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
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
Expand Down
12 changes: 6 additions & 6 deletions test/-ext-/bignum/test_mul.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
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
Expand Down Expand Up @@ -61,14 +61,14 @@ def test_mul_balance
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

Expand Down
4 changes: 2 additions & 2 deletions test/-ext-/bignum/test_str2big.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
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
Expand Down
6 changes: 3 additions & 3 deletions test/csv/test_data_converters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_convert_order_integer_float
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

Expand All @@ -114,7 +114,7 @@ def test_builtin_numeric_combo_converter
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

Expand All @@ -125,7 +125,7 @@ def test_builtin_all_nested_combo_converter
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

Expand Down
2 changes: 1 addition & 1 deletion test/date/test_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_freeze
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

Expand Down
2 changes: 1 addition & 1 deletion test/json/test_json_generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def foo.to_h
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
Expand Down
4 changes: 2 additions & 2 deletions test/minitest/test_minitest_mock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ def test_do_not_create_stub_method_on_new_mocks
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

Expand Down
4 changes: 2 additions & 2 deletions test/openssl/test_cipher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def test_crypt
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
Expand Down
2 changes: 1 addition & 1 deletion test/rexml/test_jaxen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def handleValueOf(ctx,variables, namespaces, valueOfElement)
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
Expand Down
12 changes: 6 additions & 6 deletions test/ruby/test_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def test_clone

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 })
Expand All @@ -509,8 +509,8 @@ def test_collect
# 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 } )
Expand Down Expand Up @@ -588,7 +588,7 @@ def test_count

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)
Expand Down Expand Up @@ -1074,8 +1074,8 @@ def test_length
# 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 } )
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_basicinstructions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ def get
@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
Expand Down
Loading

0 comments on commit 449fbfd

Please sign in to comment.