Skip to content

Commit 6981814

Browse files
nobueregon
authored andcommitted
Use Integer instead of Fixnum/Bignum
1 parent c953a6f commit 6981814

File tree

144 files changed

+391
-389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+391
-389
lines changed

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Spec are grouped in 5 separate top-level groups:
88

99
* `command_line`: for the ruby executable command-line flags (`-v`, `-e`, etc)
1010
* `language`: for the language keywords and syntax constructs (`if`, `def`, `A::B`, etc)
11-
* `core`: for the core methods (`Fixnum#+`, `String#upcase`, no need to require anything)
11+
* `core`: for the core methods (`Integer#+`, `String#upcase`, no need to require anything)
1212
* `library`: for the standard libraries methods (`CSV.new`, `YAML.parse`, need to require the stdlib)
1313
* `optional/capi`: for functions available to the Ruby C-extension API
1414

@@ -89,7 +89,7 @@ File.should.equal?(File) # Calls #equal? (tests identity)
8989
Numeric.should be_ancestor_of(Float) # Float.ancestors.include?(Numeric)
9090

9191
3.14.should.respond_to?(:to_i)
92-
Fixnum.should have_instance_method(:+)
92+
Integer.should have_instance_method(:+)
9393
Array.should have_method(:new)
9494
```
9595

@@ -124,8 +124,8 @@ If an exception is raised, it will fail the example anyway.
124124

125125
```ruby
126126
-> {
127-
Fixnum
128-
}.should complain(/constant ::Fixnum is deprecated/) # Expect a warning
127+
Integer
128+
}.should complain(/constant ::Integer is deprecated/) # Expect a warning
129129
```
130130

131131
### Guards

command_line/dash_e_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#needs to test return => LocalJumpError
2525

26-
describe "with -n and a Fixnum range" do
26+
describe "with -n and an Integer range" do
2727
before :each do
2828
@script = "-ne 'print if %s' #{fixture(__FILE__, "conditional_range.txt")}"
2929
end

core/argf/shared/fileno.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# returns first current file even when not yet open
1212
result << @argf.send(@method) while @argf.gets
1313
# returns last current file even when closed
14-
result.map { |d| d.class }.should == [Fixnum, Fixnum, Fixnum, Fixnum]
14+
result.map { |d| d.class }.should == [Integer, Integer, Integer, Integer]
1515
end
1616
end
1717

core/array/bsearch_index_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
@array.bsearch_index { |x| (-1) * (2**100) }.should be_nil
7878
end
7979

80-
it "handles values from Bignum#coerce" do
80+
it "handles values from Integer#coerce" do
8181
[1, 2].should include(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first })
8282
end
8383
end

core/array/first_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
-> { [1, 2].first(-1) }.should raise_error(ArgumentError)
3434
end
3535

36-
it "raises a RangeError when count is a Bignum" do
36+
it "raises a RangeError when count is an Integer" do
3737
-> { [].first(bignum_value) }.should raise_error(RangeError)
3838
end
3939

core/array/fixtures/classes.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def self.compared?
126126
attr_accessor :order
127127
end
128128

129-
class ComparableWithFixnum
129+
class ComparableWithInteger
130130
include Comparable
131131
def initialize(num)
132132
@num = num

core/array/hash_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[[], [1, 2, 3]].each do |ary|
99
ary.hash.should == ary.dup.hash
10-
ary.hash.should be_an_instance_of(Fixnum)
10+
ary.hash.should be_an_instance_of(Integer)
1111
end
1212
end
1313

core/array/sample_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
obj = mock("array_sample_random")
7070
obj.should_receive(:rand).and_return(0.5)
7171

72-
[1, 2].sample(random: obj).should be_an_instance_of(Fixnum)
72+
[1, 2].sample(random: obj).should be_an_instance_of(Integer)
7373
end
7474

7575
it "raises a NoMethodError if an object passed for the RNG does not define #rand" do
@@ -78,8 +78,8 @@
7878
-> { [1, 2].sample(random: obj) }.should raise_error(NoMethodError)
7979
end
8080

81-
describe "when the object returned by #rand is a Fixnum" do
82-
it "uses the fixnum as index" do
81+
describe "when the object returned by #rand is an Integer" do
82+
it "uses the integer as index" do
8383
random = mock("array_sample_random_ret")
8484
random.should_receive(:rand).and_return(0)
8585

@@ -107,7 +107,7 @@
107107
end
108108
end
109109

110-
describe "when the object returned by #rand is not a Fixnum but responds to #to_int" do
110+
describe "when the object returned by #rand is not an Integer but responds to #to_int" do
111111
it "calls #to_int on the Object" do
112112
value = mock("array_sample_random_value")
113113
value.should_receive(:to_int).and_return(1)

core/array/shared/slice.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def to.to_int() -2 end
486486
end
487487
end
488488

489-
it "raises a RangeError when the start index is out of range of Fixnum" do
489+
it "raises a RangeError when the start index is out of range of Integer" do
490490
array = [1, 2, 3, 4, 5, 6]
491491
obj = mock('large value')
492492
obj.should_receive(:to_int).and_return(bignum_value)
@@ -502,7 +502,7 @@ def to.to_int() -2 end
502502
array.send(@method, max_long.to_f.prev_float).should == nil
503503
end
504504

505-
it "raises a RangeError when the length is out of range of Fixnum" do
505+
it "raises a RangeError when the length is out of range of Integer" do
506506
array = [1, 2, 3, 4, 5, 6]
507507
obj = mock('large value')
508508
obj.should_receive(:to_int).and_return(bignum_value)

core/array/shared/union.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
[0].send(@method, obj).should == ([0] | [1, 2, 3])
3232
end
3333

34-
# MRI follows hashing semantics here, so doesn't actually call eql?/hash for Fixnum/Symbol
34+
# MRI follows hashing semantics here, so doesn't actually call eql?/hash for Integer/Symbol
3535
it "acts as if using an intermediate hash to collect values" do
3636
not_supported_on :opal do
3737
[5.0, 4.0].send(@method, [5, 4]).should == [5.0, 4.0, 5, 4]

core/array/sort_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,18 @@
111111
[1, 2, 3].sort{ break :a }.should == :a
112112
end
113113

114-
it "uses the sign of Bignum block results as the sort result" do
114+
it "uses the sign of Integer block results as the sort result" do
115115
a = [1, 2, 5, 10, 7, -4, 12]
116116
begin
117-
class Bignum;
117+
class Integer
118118
alias old_spaceship <=>
119119
def <=>(other)
120120
raise
121121
end
122122
end
123123
a.sort {|n, m| (n - m) * (2 ** 200)}.should == [-4, 1, 2, 5, 7, 10, 12]
124124
ensure
125-
class Bignum
125+
class Integer
126126
alias <=> old_spaceship
127127
end
128128
end
@@ -132,7 +132,7 @@ class Bignum
132132
a = [1, 2, 5, 10, 7, -4, 12]
133133
a.sort { |n, m| n - m }.should == [-4, 1, 2, 5, 7, 10, 12]
134134
a.sort { |n, m|
135-
ArraySpecs::ComparableWithFixnum.new(n-m)
135+
ArraySpecs::ComparableWithInteger.new(n-m)
136136
}.should == [-4, 1, 2, 5, 7, 10, 12]
137137
-> {
138138
a.sort { |n, m| (n - m).to_s }

core/basicobject/instance_eval_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ class B; end
131131
end
132132

133133
quarantine! do # Not clean, leaves cvars lying around to break other specs
134-
it "scopes class var accesses in the caller when called on a Fixnum" do
135-
# Fixnum can take instance vars
136-
Fixnum.class_eval "@@__tmp_instance_eval_spec = 1"
134+
it "scopes class var accesses in the caller when called on an Integer" do
135+
# Integer can take instance vars
136+
Integer.class_eval "@@__tmp_instance_eval_spec = 1"
137137
(defined? @@__tmp_instance_eval_spec).should be_nil
138138

139139
@@__tmp_instance_eval_spec = 2
140140
1.instance_eval { @@__tmp_instance_eval_spec }.should == 2
141-
Fixnum.__send__(:remove_class_variable, :@@__tmp_instance_eval_spec)
141+
Integer.__send__(:remove_class_variable, :@@__tmp_instance_eval_spec)
142142
end
143143
end
144144

core/basicobject/instance_exec_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ def foo
8585
end
8686

8787
quarantine! do # Not clean, leaves cvars lying around to break other specs
88-
it "scopes class var accesses in the caller when called on a Fixnum" do
89-
# Fixnum can take instance vars
90-
Fixnum.class_eval "@@__tmp_instance_exec_spec = 1"
88+
it "scopes class var accesses in the caller when called on an Integer" do
89+
# Integer can take instance vars
90+
Integer.class_eval "@@__tmp_instance_exec_spec = 1"
9191
(defined? @@__tmp_instance_exec_spec).should == nil
9292

9393
@@__tmp_instance_exec_spec = 2
9494
1.instance_exec { @@__tmp_instance_exec_spec }.should == 2
95-
Fixnum.__send__(:remove_class_variable, :@@__tmp_instance_exec_spec)
95+
Integer.__send__(:remove_class_variable, :@@__tmp_instance_exec_spec)
9696
end
9797
end
9898

core/builtin_constants/builtin_constants_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
end
88

99
describe "RUBY_PATCHLEVEL" do
10-
it "is a Fixnum" do
11-
RUBY_PATCHLEVEL.should be_kind_of(Fixnum)
10+
it "is an Integer" do
11+
RUBY_PATCHLEVEL.should be_kind_of(Integer)
1212
end
1313
end
1414

@@ -51,7 +51,7 @@
5151
describe "RUBY_REVISION" do
5252
ruby_version_is ""..."2.7" do
5353
it "is an Integer" do
54-
RUBY_REVISION.should be_kind_of(Fixnum)
54+
RUBY_REVISION.should be_kind_of(Integer)
5555
end
5656
end
5757

core/class/initialize_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
it "raises a TypeError when called on already initialized classes" do
99
->{
10-
Fixnum.send :initialize
10+
Integer.send :initialize
1111
}.should raise_error(TypeError)
1212

1313
->{

core/class/superclass_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Class.superclass.should == Module
99
Class.new.superclass.should == Object
1010
Class.new(String).superclass.should == String
11-
Class.new(Fixnum).superclass.should == Fixnum
11+
Class.new(Integer).superclass.should == Integer
1212
end
1313

1414
# redmine:567

core/complex/coerce_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
result.last.should be_kind_of(Complex)
2020
end
2121

22-
it "returns an array containing other and self as Complex when other is a Bignum" do
22+
it "returns an array containing other and self as Complex when other is an Integer" do
2323
result = @one.coerce(4294967296)
2424
result.should == [4294967296, 1]
2525
result.first.should be_kind_of(Complex)

core/complex/equal_value_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
end
5454

5555
describe "with Object" do
56-
# Fixnum#==, Float#== and Bignum#== only return booleans - Bug?
56+
# Integer#== and Float#== only return booleans - Bug?
5757
it "calls other#== with self" do
5858
value = Complex(3, 0)
5959

core/complex/exponent_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative '../../spec_helper'
22

33
describe "Complex#**" do
4-
describe "with Fixnum 0" do
4+
describe "with Integer 0" do
55
it "returns Complex(1)" do
66
(Complex(3, 4) ** 0).should eql(Complex(1))
77
end

core/complex/shared/divide.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
end
1313
end
1414

15-
describe "with Fixnum" do
15+
describe "with Integer" do
1616
it "divides both parts of the Complex number" do
1717
Complex(20, 40).send(@method, 2).should == Complex(10, 20)
1818
Complex(30, 30).send(@method, 10).should == Complex(3, 3)
@@ -27,7 +27,7 @@
2727
end
2828
end
2929

30-
describe "with Bignum" do
30+
describe "with Integer" do
3131
it "divides both parts of the Complex number" do
3232
Complex(20, 40).send(@method, 2).should == Complex(10, 20)
3333
Complex(15, 16).send(@method, 2.0).should be_close(Complex(7.5, 8), TOLERANCE)

core/complex/to_f_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative '../../spec_helper'
22

33
describe "Complex#to_f" do
4-
describe "when the imaginary part is Fixnum 0" do
4+
describe "when the imaginary part is Integer 0" do
55
it "returns the result of sending #to_f to the real part" do
66
real = mock_numeric('real')
77
real.should_receive(:to_f).and_return(:f)

core/complex/to_i_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative '../../spec_helper'
22

33
describe "Complex#to_i" do
4-
describe "when the imaginary part is Fixnum 0" do
4+
describe "when the imaginary part is Integer 0" do
55
it "returns the result of sending #to_i to the real part" do
66
real = mock_numeric('real')
77
real.should_receive(:to_i).and_return(:i)

core/complex/to_r_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative '../../spec_helper'
22

33
describe "Complex#to_r" do
4-
describe "when the imaginary part is Fixnum 0" do
4+
describe "when the imaginary part is Integer 0" do
55
it "returns the result of sending #to_r to the real part" do
66
real = mock_numeric('real')
77
real.should_receive(:to_r).and_return(:r)

core/dir/fileno_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
if has_dir_fileno
2929
it "returns the file descriptor of the dir" do
30-
@dir.fileno.should be_kind_of(Fixnum)
30+
@dir.fileno.should be_kind_of(Integer)
3131
end
3232
else
3333
it "raises an error when not implemented on the platform" do

0 commit comments

Comments
 (0)