diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-12-21 01:16:26 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-12-21 01:19:55 +0900 |
commit | 9c73c756244fa27ffa99d81dcc73a4ad14198002 (patch) | |
tree | 14b0ea9059b8c31e276531a1df712ead4e158cdb /spec/ruby/core/array | |
parent | fb8f011422c645ebe29e94c3fb2079af73d1d35f (diff) |
Use Integer instead of Fixnum/Bignum
Diffstat (limited to 'spec/ruby/core/array')
-rw-r--r-- | spec/ruby/core/array/bsearch_index_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/first_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/fixtures/classes.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/hash_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/sample_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/core/array/shared/slice.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/array/shared/union.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/sort_spec.rb | 8 |
8 files changed, 15 insertions, 15 deletions
diff --git a/spec/ruby/core/array/bsearch_index_spec.rb b/spec/ruby/core/array/bsearch_index_spec.rb index aafded178d..df2c7c098e 100644 --- a/spec/ruby/core/array/bsearch_index_spec.rb +++ b/spec/ruby/core/array/bsearch_index_spec.rb @@ -77,7 +77,7 @@ describe "Array#bsearch_index" do @array.bsearch_index { |x| (-1) * (2**100) }.should be_nil end - it "handles values from Bignum#coerce" do + it "handles values from Integer#coerce" do [1, 2].should include(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first }) end end diff --git a/spec/ruby/core/array/first_spec.rb b/spec/ruby/core/array/first_spec.rb index 66eeba6565..463da829a2 100644 --- a/spec/ruby/core/array/first_spec.rb +++ b/spec/ruby/core/array/first_spec.rb @@ -33,7 +33,7 @@ describe "Array#first" do -> { [1, 2].first(-1) }.should raise_error(ArgumentError) end - it "raises a RangeError when count is a Bignum" do + it "raises a RangeError when count is an Integer" do -> { [].first(bignum_value) }.should raise_error(RangeError) end diff --git a/spec/ruby/core/array/fixtures/classes.rb b/spec/ruby/core/array/fixtures/classes.rb index 2791a2eb5d..affb3b49e6 100644 --- a/spec/ruby/core/array/fixtures/classes.rb +++ b/spec/ruby/core/array/fixtures/classes.rb @@ -126,7 +126,7 @@ module ArraySpecs attr_accessor :order end - class ComparableWithFixnum + class ComparableWithInteger include Comparable def initialize(num) @num = num diff --git a/spec/ruby/core/array/hash_spec.rb b/spec/ruby/core/array/hash_spec.rb index 8392253ae4..f3bcc83fce 100644 --- a/spec/ruby/core/array/hash_spec.rb +++ b/spec/ruby/core/array/hash_spec.rb @@ -7,7 +7,7 @@ describe "Array#hash" do [[], [1, 2, 3]].each do |ary| ary.hash.should == ary.dup.hash - ary.hash.should be_an_instance_of(Fixnum) + ary.hash.should be_an_instance_of(Integer) end end diff --git a/spec/ruby/core/array/sample_spec.rb b/spec/ruby/core/array/sample_spec.rb index 73b6bdf480..565d7ff7f9 100644 --- a/spec/ruby/core/array/sample_spec.rb +++ b/spec/ruby/core/array/sample_spec.rb @@ -69,7 +69,7 @@ describe "Array#sample" do obj = mock("array_sample_random") obj.should_receive(:rand).and_return(0.5) - [1, 2].sample(random: obj).should be_an_instance_of(Fixnum) + [1, 2].sample(random: obj).should be_an_instance_of(Integer) end it "raises a NoMethodError if an object passed for the RNG does not define #rand" do @@ -78,8 +78,8 @@ describe "Array#sample" do -> { [1, 2].sample(random: obj) }.should raise_error(NoMethodError) end - describe "when the object returned by #rand is a Fixnum" do - it "uses the fixnum as index" do + describe "when the object returned by #rand is an Integer" do + it "uses the integer as index" do random = mock("array_sample_random_ret") random.should_receive(:rand).and_return(0) @@ -107,7 +107,7 @@ describe "Array#sample" do end end - describe "when the object returned by #rand is not a Fixnum but responds to #to_int" do + describe "when the object returned by #rand is not an Integer but responds to #to_int" do it "calls #to_int on the Object" do value = mock("array_sample_random_value") value.should_receive(:to_int).and_return(1) diff --git a/spec/ruby/core/array/shared/slice.rb b/spec/ruby/core/array/shared/slice.rb index 845be768c6..820047cdb2 100644 --- a/spec/ruby/core/array/shared/slice.rb +++ b/spec/ruby/core/array/shared/slice.rb @@ -486,7 +486,7 @@ describe :array_slice, shared: true do end end - it "raises a RangeError when the start index is out of range of Fixnum" do + it "raises a RangeError when the start index is out of range of Integer" do array = [1, 2, 3, 4, 5, 6] obj = mock('large value') obj.should_receive(:to_int).and_return(bignum_value) @@ -502,7 +502,7 @@ describe :array_slice, shared: true do array.send(@method, max_long.to_f.prev_float).should == nil end - it "raises a RangeError when the length is out of range of Fixnum" do + it "raises a RangeError when the length is out of range of Integer" do array = [1, 2, 3, 4, 5, 6] obj = mock('large value') obj.should_receive(:to_int).and_return(bignum_value) diff --git a/spec/ruby/core/array/shared/union.rb b/spec/ruby/core/array/shared/union.rb index 12a98cc9fe..0b60df9ca4 100644 --- a/spec/ruby/core/array/shared/union.rb +++ b/spec/ruby/core/array/shared/union.rb @@ -31,7 +31,7 @@ describe :array_binary_union, shared: true do [0].send(@method, obj).should == ([0] | [1, 2, 3]) end - # MRI follows hashing semantics here, so doesn't actually call eql?/hash for Fixnum/Symbol + # MRI follows hashing semantics here, so doesn't actually call eql?/hash for Integer/Symbol it "acts as if using an intermediate hash to collect values" do not_supported_on :opal do [5.0, 4.0].send(@method, [5, 4]).should == [5.0, 4.0, 5, 4] diff --git a/spec/ruby/core/array/sort_spec.rb b/spec/ruby/core/array/sort_spec.rb index 0c5ecdcbbf..e20b650516 100644 --- a/spec/ruby/core/array/sort_spec.rb +++ b/spec/ruby/core/array/sort_spec.rb @@ -111,10 +111,10 @@ describe "Array#sort" do [1, 2, 3].sort{ break :a }.should == :a end - it "uses the sign of Bignum block results as the sort result" do + it "uses the sign of Integer block results as the sort result" do a = [1, 2, 5, 10, 7, -4, 12] begin - class Bignum; + class Integer alias old_spaceship <=> def <=>(other) raise @@ -122,7 +122,7 @@ describe "Array#sort" do end a.sort {|n, m| (n - m) * (2 ** 200)}.should == [-4, 1, 2, 5, 7, 10, 12] ensure - class Bignum + class Integer alias <=> old_spaceship end end @@ -132,7 +132,7 @@ describe "Array#sort" do a = [1, 2, 5, 10, 7, -4, 12] a.sort { |n, m| n - m }.should == [-4, 1, 2, 5, 7, 10, 12] a.sort { |n, m| - ArraySpecs::ComparableWithFixnum.new(n-m) + ArraySpecs::ComparableWithInteger.new(n-m) }.should == [-4, 1, 2, 5, 7, 10, 12] -> { a.sort { |n, m| (n - m).to_s } |