[前][次][番号順一覧][スレッド一覧]

ruby-changes:64390

From: Nobuyoshi <ko1@a...>
Date: Mon, 21 Dec 2020 01:20:14 +0900 (JST)
Subject: [ruby-changes:64390] 9c73c75624 (master): Use Integer instead of Fixnum/Bignum

https://git.ruby-lang.org/ruby.git/commit/?id=9c73c75624

From 9c73c756244fa27ffa99d81dcc73a4ad14198002 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 21 Dec 2020 01:16:26 +0900
Subject: Use Integer instead of Fixnum/Bignum


diff --git a/spec/ruby/CONTRIBUTING.md b/spec/ruby/CONTRIBUTING.md
index 9a2a341..56e1273 100644
--- a/spec/ruby/CONTRIBUTING.md
+++ b/spec/ruby/CONTRIBUTING.md
@@ -8,7 +8,7 @@ Spec are grouped in 5 separate top-level groups: https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L8
 
 * `command_line`: for the ruby executable command-line flags (`-v`, `-e`, etc)
 * `language`: for the language keywords and syntax constructs (`if`, `def`, `A::B`, etc)
-* `core`: for the core methods (`Fixnum#+`, `String#upcase`, no need to require anything)
+* `core`: for the core methods (`Integer#+`, `String#upcase`, no need to require anything)
 * `library`: for the standard libraries methods (`CSV.new`, `YAML.parse`, need to require the stdlib)
 * `optional/capi`: for functions available to the Ruby C-extension API
 
@@ -89,7 +89,7 @@ File.should.equal?(File) # Calls #equal? (tests identity) https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L89
 Numeric.should be_ancestor_of(Float) # Float.ancestors.include?(Numeric)
 
 3.14.should.respond_to?(:to_i)
-Fixnum.should have_instance_method(:+)
+Integer.should have_instance_method(:+)
 Array.should have_method(:new)
 ```
 
@@ -124,8 +124,8 @@ If an exception is raised, it will fail the example anyway. https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L124
 
 ```ruby
 -> {
-  Fixnum
-}.should complain(/constant ::Fixnum is deprecated/) # Expect a warning
+  Integer
+}.should complain(/constant ::Integer is deprecated/) # Expect a warning
 ```
 
 ### Guards
diff --git a/spec/ruby/command_line/dash_e_spec.rb b/spec/ruby/command_line/dash_e_spec.rb
index 9f600eb..24ed343 100644
--- a/spec/ruby/command_line/dash_e_spec.rb
+++ b/spec/ruby/command_line/dash_e_spec.rb
@@ -23,7 +23,7 @@ describe "The -e command line option" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_e_spec.rb#L23
 
   #needs to test return => LocalJumpError
 
-  describe "with -n and a Fixnum range" do
+  describe "with -n and an Integer range" do
     before :each do
       @script = "-ne 'print if %s' #{fixture(__FILE__, "conditional_range.txt")}"
     end
diff --git a/spec/ruby/core/argf/shared/fileno.rb b/spec/ruby/core/argf/shared/fileno.rb
index 5d67404..4350d43 100644
--- a/spec/ruby/core/argf/shared/fileno.rb
+++ b/spec/ruby/core/argf/shared/fileno.rb
@@ -11,7 +11,7 @@ describe :argf_fileno, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/argf/shared/fileno.rb#L11
       # returns first current file even when not yet open
       result << @argf.send(@method) while @argf.gets
       # returns last current file even when closed
-      result.map { |d| d.class }.should == [Fixnum, Fixnum, Fixnum, Fixnum]
+      result.map { |d| d.class }.should == [Integer, Integer, Integer, Integer]
     end
   end
 
diff --git a/spec/ruby/core/array/bsearch_index_spec.rb b/spec/ruby/core/array/bsearch_index_spec.rb
index aafded1..df2c7c0 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/bsearch_index_spec.rb#L77
         @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 66eeba6..463da82 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/first_spec.rb#L33
     -> { [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 2791a2e..affb3b4 100644
--- a/spec/ruby/core/array/fixtures/classes.rb
+++ b/spec/ruby/core/array/fixtures/classes.rb
@@ -126,7 +126,7 @@ module ArraySpecs https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/fixtures/classes.rb#L126
     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 8392253..f3bcc83 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/hash_spec.rb#L7
 
     [[], [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 73b6bdf..565d7ff 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/sample_spec.rb#L69
       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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/sample_spec.rb#L78
       -> { [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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/sample_spec.rb#L107
     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 845be76..820047c 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/slice.rb#L486
     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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/slice.rb#L502
     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 12a98cc..0b60df9 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/union.rb#L31
     [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 0c5ecdc..e20b650 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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/sort_spec.rb#L111
     [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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/sort_spec.rb#L122
       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 https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/sort_spec.rb#L132
     a = [1, 2, 5, 10, 7, -4, 12] (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]