1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Use Integer instead of Fixnum/Bignum

This commit is contained in:
Nobuyoshi Nakada 2020-12-21 01:16:26 +09:00
parent fb8f011422
commit 9c73c75624
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
144 changed files with 392 additions and 390 deletions

View file

@ -8,7 +8,7 @@ Spec are grouped in 5 separate top-level groups:
* `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)
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.
```ruby
-> {
Fixnum
}.should complain(/constant ::Fixnum is deprecated/) # Expect a warning
Integer
}.should complain(/constant ::Integer is deprecated/) # Expect a warning
```
### Guards

View file

@ -23,7 +23,7 @@ describe "The -e command line option" do
#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

View file

@ -11,7 +11,7 @@ describe :argf_fileno, shared: true do
# 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

View file

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

View file

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

View file

@ -126,7 +126,7 @@ module ArraySpecs
attr_accessor :order
end
class ComparableWithFixnum
class ComparableWithInteger
include Comparable
def initialize(num)
@num = num

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -131,14 +131,14 @@ describe "BasicObject#instance_eval" do
end
quarantine! do # Not clean, leaves cvars lying around to break other specs
it "scopes class var accesses in the caller when called on a Fixnum" do
# Fixnum can take instance vars
Fixnum.class_eval "@@__tmp_instance_eval_spec = 1"
it "scopes class var accesses in the caller when called on an Integer" do
# Integer can take instance vars
Integer.class_eval "@@__tmp_instance_eval_spec = 1"
(defined? @@__tmp_instance_eval_spec).should be_nil
@@__tmp_instance_eval_spec = 2
1.instance_eval { @@__tmp_instance_eval_spec }.should == 2
Fixnum.__send__(:remove_class_variable, :@@__tmp_instance_eval_spec)
Integer.__send__(:remove_class_variable, :@@__tmp_instance_eval_spec)
end
end

View file

@ -85,14 +85,14 @@ describe "BasicObject#instance_exec" do
end
quarantine! do # Not clean, leaves cvars lying around to break other specs
it "scopes class var accesses in the caller when called on a Fixnum" do
# Fixnum can take instance vars
Fixnum.class_eval "@@__tmp_instance_exec_spec = 1"
it "scopes class var accesses in the caller when called on an Integer" do
# Integer can take instance vars
Integer.class_eval "@@__tmp_instance_exec_spec = 1"
(defined? @@__tmp_instance_exec_spec).should == nil
@@__tmp_instance_exec_spec = 2
1.instance_exec { @@__tmp_instance_exec_spec }.should == 2
Fixnum.__send__(:remove_class_variable, :@@__tmp_instance_exec_spec)
Integer.__send__(:remove_class_variable, :@@__tmp_instance_exec_spec)
end
end

View file

@ -7,8 +7,8 @@ describe "RUBY_VERSION" do
end
describe "RUBY_PATCHLEVEL" do
it "is a Fixnum" do
RUBY_PATCHLEVEL.should be_kind_of(Fixnum)
it "is an Integer" do
RUBY_PATCHLEVEL.should be_kind_of(Integer)
end
end
@ -51,7 +51,7 @@ end
describe "RUBY_REVISION" do
ruby_version_is ""..."2.7" do
it "is an Integer" do
RUBY_REVISION.should be_kind_of(Fixnum)
RUBY_REVISION.should be_kind_of(Integer)
end
end

View file

@ -7,7 +7,7 @@ describe "Class#initialize" do
it "raises a TypeError when called on already initialized classes" do
->{
Fixnum.send :initialize
Integer.send :initialize
}.should raise_error(TypeError)
->{

View file

@ -8,7 +8,7 @@ describe "Class#superclass" do
Class.superclass.should == Module
Class.new.superclass.should == Object
Class.new(String).superclass.should == String
Class.new(Fixnum).superclass.should == Fixnum
Class.new(Integer).superclass.should == Integer
end
# redmine:567

View file

@ -19,7 +19,7 @@ describe "Complex#coerce" do
result.last.should be_kind_of(Complex)
end
it "returns an array containing other and self as Complex when other is a Bignum" do
it "returns an array containing other and self as Complex when other is an Integer" do
result = @one.coerce(4294967296)
result.should == [4294967296, 1]
result.first.should be_kind_of(Complex)

View file

@ -53,7 +53,7 @@ describe "Complex#==" do
end
describe "with Object" do
# Fixnum#==, Float#== and Bignum#== only return booleans - Bug?
# Integer#== and Float#== only return booleans - Bug?
it "calls other#== with self" do
value = Complex(3, 0)

View file

@ -1,7 +1,7 @@
require_relative '../../spec_helper'
describe "Complex#**" do
describe "with Fixnum 0" do
describe "with Integer 0" do
it "returns Complex(1)" do
(Complex(3, 4) ** 0).should eql(Complex(1))
end

View file

@ -12,7 +12,7 @@ describe :complex_divide, shared: true do
end
end
describe "with Fixnum" do
describe "with Integer" do
it "divides both parts of the Complex number" do
Complex(20, 40).send(@method, 2).should == Complex(10, 20)
Complex(30, 30).send(@method, 10).should == Complex(3, 3)
@ -27,7 +27,7 @@ describe :complex_divide, shared: true do
end
end
describe "with Bignum" do
describe "with Integer" do
it "divides both parts of the Complex number" do
Complex(20, 40).send(@method, 2).should == Complex(10, 20)
Complex(15, 16).send(@method, 2.0).should be_close(Complex(7.5, 8), TOLERANCE)

View file

@ -1,7 +1,7 @@
require_relative '../../spec_helper'
describe "Complex#to_f" do
describe "when the imaginary part is Fixnum 0" do
describe "when the imaginary part is Integer 0" do
it "returns the result of sending #to_f to the real part" do
real = mock_numeric('real')
real.should_receive(:to_f).and_return(:f)

View file

@ -1,7 +1,7 @@
require_relative '../../spec_helper'
describe "Complex#to_i" do
describe "when the imaginary part is Fixnum 0" do
describe "when the imaginary part is Integer 0" do
it "returns the result of sending #to_i to the real part" do
real = mock_numeric('real')
real.should_receive(:to_i).and_return(:i)

View file

@ -1,7 +1,7 @@
require_relative '../../spec_helper'
describe "Complex#to_r" do
describe "when the imaginary part is Fixnum 0" do
describe "when the imaginary part is Integer 0" do
it "returns the result of sending #to_r to the real part" do
real = mock_numeric('real')
real.should_receive(:to_r).and_return(:r)

View file

@ -27,7 +27,7 @@ describe "Dir#fileno" do
if has_dir_fileno
it "returns the file descriptor of the dir" do
@dir.fileno.should be_kind_of(Fixnum)
@dir.fileno.should be_kind_of(Integer)
end
else
it "raises an error when not implemented on the platform" do

View file

@ -5,8 +5,8 @@ describe "Encoding::Converter::INVALID_MASK" do
Encoding::Converter.should have_constant(:INVALID_MASK)
end
it "has a Fixnum value" do
Encoding::Converter::INVALID_MASK.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::INVALID_MASK.should be_an_instance_of(Integer)
end
end
@ -15,8 +15,8 @@ describe "Encoding::Converter::INVALID_REPLACE" do
Encoding::Converter.should have_constant(:INVALID_REPLACE)
end
it "has a Fixnum value" do
Encoding::Converter::INVALID_REPLACE.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::INVALID_REPLACE.should be_an_instance_of(Integer)
end
end
@ -25,8 +25,8 @@ describe "Encoding::Converter::UNDEF_MASK" do
Encoding::Converter.should have_constant(:UNDEF_MASK)
end
it "has a Fixnum value" do
Encoding::Converter::UNDEF_MASK.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::UNDEF_MASK.should be_an_instance_of(Integer)
end
end
@ -35,8 +35,8 @@ describe "Encoding::Converter::UNDEF_REPLACE" do
Encoding::Converter.should have_constant(:UNDEF_REPLACE)
end
it "has a Fixnum value" do
Encoding::Converter::UNDEF_REPLACE.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::UNDEF_REPLACE.should be_an_instance_of(Integer)
end
end
@ -45,8 +45,8 @@ describe "Encoding::Converter::UNDEF_HEX_CHARREF" do
Encoding::Converter.should have_constant(:UNDEF_HEX_CHARREF)
end
it "has a Fixnum value" do
Encoding::Converter::UNDEF_HEX_CHARREF.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::UNDEF_HEX_CHARREF.should be_an_instance_of(Integer)
end
end
@ -55,8 +55,8 @@ describe "Encoding::Converter::PARTIAL_INPUT" do
Encoding::Converter.should have_constant(:PARTIAL_INPUT)
end
it "has a Fixnum value" do
Encoding::Converter::PARTIAL_INPUT.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::PARTIAL_INPUT.should be_an_instance_of(Integer)
end
end
@ -65,8 +65,8 @@ describe "Encoding::Converter::AFTER_OUTPUT" do
Encoding::Converter.should have_constant(:AFTER_OUTPUT)
end
it "has a Fixnum value" do
Encoding::Converter::AFTER_OUTPUT.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::AFTER_OUTPUT.should be_an_instance_of(Integer)
end
end
@ -75,8 +75,8 @@ describe "Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR" do
Encoding::Converter.should have_constant(:UNIVERSAL_NEWLINE_DECORATOR)
end
it "has a Fixnum value" do
Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR.should be_an_instance_of(Integer)
end
end
@ -85,8 +85,8 @@ describe "Encoding::Converter::CRLF_NEWLINE_DECORATOR" do
Encoding::Converter.should have_constant(:CRLF_NEWLINE_DECORATOR)
end
it "has a Fixnum value" do
Encoding::Converter::CRLF_NEWLINE_DECORATOR.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::CRLF_NEWLINE_DECORATOR.should be_an_instance_of(Integer)
end
end
@ -95,8 +95,8 @@ describe "Encoding::Converter::CR_NEWLINE_DECORATOR" do
Encoding::Converter.should have_constant(:CR_NEWLINE_DECORATOR)
end
it "has a Fixnum value" do
Encoding::Converter::CR_NEWLINE_DECORATOR.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::CR_NEWLINE_DECORATOR.should be_an_instance_of(Integer)
end
end
@ -105,8 +105,8 @@ describe "Encoding::Converter::XML_TEXT_DECORATOR" do
Encoding::Converter.should have_constant(:XML_TEXT_DECORATOR)
end
it "has a Fixnum value" do
Encoding::Converter::XML_TEXT_DECORATOR.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::XML_TEXT_DECORATOR.should be_an_instance_of(Integer)
end
end
@ -115,8 +115,8 @@ describe "Encoding::Converter::XML_ATTR_CONTENT_DECORATOR" do
Encoding::Converter.should have_constant(:XML_ATTR_CONTENT_DECORATOR)
end
it "has a Fixnum value" do
Encoding::Converter::XML_ATTR_CONTENT_DECORATOR.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::XML_ATTR_CONTENT_DECORATOR.should be_an_instance_of(Integer)
end
end
@ -125,7 +125,7 @@ describe "Encoding::Converter::XML_ATTR_QUOTE_DECORATOR" do
Encoding::Converter.should have_constant(:XML_ATTR_QUOTE_DECORATOR)
end
it "has a Fixnum value" do
Encoding::Converter::XML_ATTR_QUOTE_DECORATOR.should be_an_instance_of(Fixnum)
it "has an Integer value" do
Encoding::Converter::XML_ATTR_QUOTE_DECORATOR.should be_an_instance_of(Integer)
end
end

View file

@ -47,7 +47,7 @@ describe "Encoding::Converter.new" do
conv.replacement.should == "fubar"
end
it "calls #to_hash to convert the options argument to a Hash if not a Fixnum" do
it "calls #to_hash to convert the options argument to a Hash if not an Integer" do
opts = mock("encoding converter options")
opts.should_receive(:to_hash).and_return({ replace: "fubar" })
conv = Encoding::Converter.new("us-ascii", "utf-8", **opts)
@ -82,7 +82,7 @@ describe "Encoding::Converter.new" do
end.should raise_error(TypeError)
end
it "raises a TypeError if passed a Fixnum for the replacement object" do
it "raises a TypeError if passed an Integer for the replacement object" do
-> do
Encoding::Converter.new("us-ascii", "utf-8", replace: 1)
end.should raise_error(TypeError)

View file

@ -17,7 +17,7 @@ describe "Enumerable#first" do
EnumerableSpecs::YieldsMixed2.new.to_enum.first.should == nil
end
it "raises a RangeError when passed a Bignum" do
it "raises a RangeError when passed an Integer" do
enum = EnumerableSpecs::Empty.new
-> { enum.first(bignum_value) }.should raise_error(RangeError)
end

View file

@ -251,7 +251,7 @@ module EnumerableSpecs
end
end
class ComparableWithFixnum
class ComparableWithInteger
include Comparable
def initialize(num)
@num = num

View file

@ -31,7 +31,7 @@ describe "Enumerable#sort" do
it "compare values returned by block with 0" do
EnumerableSpecs::Numerous.new.sort { |n, m| -(n+m) * (n <=> m) }.should == [6, 5, 4, 3, 2, 1]
EnumerableSpecs::Numerous.new.sort { |n, m|
EnumerableSpecs::ComparableWithFixnum.new(-(n+m) * (n <=> m))
EnumerableSpecs::ComparableWithInteger.new(-(n+m) * (n <=> m))
}.should == [6, 5, 4, 3, 2, 1]
-> {
EnumerableSpecs::Numerous.new.sort { |n, m| (n <=> m).to_s }

View file

@ -43,7 +43,7 @@ describe "Enumerator#initialize" do
@uninitialized.send(:initialize, Float::INFINITY) {}.size.should equal(Float::INFINITY)
end
it "sets size to the given size if the given size is a Fixnum" do
it "sets size to the given size if the given size is an Integer" do
@uninitialized.send(:initialize, 100) {}.size.should == 100
end

View file

@ -43,7 +43,7 @@ describe "Enumerator::Lazy#initialize" do
@uninitialized.send(:initialize, @receiver, Float::INFINITY) {}.size.should equal(Float::INFINITY)
end
it "sets given size to own size if the given size is a Fixnum" do
it "sets given size to own size if the given size is an Integer" do
@uninitialized.send(:initialize, @receiver, 100) {}.size.should == 100
end

View file

@ -31,7 +31,7 @@ describe "SystemCallError.new" do
-> { SystemCallError.new }.should raise_error(ArgumentError)
end
it "accepts single Fixnum argument as errno" do
it "accepts single Integer argument as errno" do
SystemCallError.new(-2**24).errno.should == -2**24
SystemCallError.new(-1).errno.should == -1
SystemCallError.new(0).errno.should == 0

View file

@ -59,8 +59,8 @@ describe "File#size" do
@file.respond_to?(:size).should be_true
end
it "returns the file's size as a Fixnum" do
@file.size.should be_an_instance_of(Fixnum)
it "returns the file's size as an Integer" do
@file.size.should be_an_instance_of(Integer)
end
it "returns the file's size in bytes" do

View file

@ -12,8 +12,8 @@ describe "File.umask" do
File.umask(@orig_umask)
end
it "returns a Fixnum" do
File.umask.should be_kind_of(Fixnum)
it "returns an Integer" do
File.umask.should be_kind_of(Integer)
end
platform_is_not :windows do

View file

@ -48,7 +48,7 @@ describe "Float#<=>" do
# The 4 tests below are taken from matz's revision 23730 for Ruby trunk
#
it "returns 1 when self is Infinity and other is a Bignum" do
it "returns 1 when self is Infinity and other is an Integer" do
(infinity_value <=> Float::MAX.to_i*2).should == 1
end

View file

@ -1,9 +1,9 @@
describe :float_quo, shared: true do
it "performs floating-point division between self and a Fixnum" do
it "performs floating-point division between self and an Integer" do
8.9.send(@method, 7).should == 1.2714285714285716
end
it "performs floating-point division between self and a Bignum" do
it "performs floating-point division between self and an Integer" do
8.9.send(@method, 9999999999999**9).should == 8.900000000008011e-117
end

View file

@ -36,7 +36,7 @@ describe :hash_store, shared: true do
h[key].should == "foo"
end
it " accepts keys with a Bignum hash" do
it " accepts keys with an Integer hash" do
o = mock(hash: 1 << 100)
h = {}
h[o] = 1

View file

@ -4,10 +4,10 @@ require 'bigdecimal'
describe "Integer#coerce" do
context "fixnum" do
describe "when given a Fixnum" do
it "returns an array containing two Fixnums" do
describe "when given an Integer" do
it "returns an array containing two Integers" do
1.coerce(2).should == [2, 1]
1.coerce(2).map { |i| i.class }.should == [Fixnum, Fixnum]
1.coerce(2).map { |i| i.class }.should == [Integer, Integer]
end
end
@ -42,26 +42,26 @@ describe "Integer#coerce" do
end
context "bignum" do
it "coerces other to a Bignum and returns [other, self] when passed a Fixnum" do
it "coerces other to an Integer and returns [other, self] when passed an Integer" do
a = bignum_value
ary = a.coerce(2)
ary[0].should be_kind_of(Bignum)
ary[1].should be_kind_of(Bignum)
ary[0].should be_kind_of(Integer)
ary[1].should be_kind_of(Integer)
ary.should == [2, a]
end
it "returns [other, self] when passed a Bignum" do
it "returns [other, self] when passed an Integer" do
a = bignum_value
b = bignum_value
ary = a.coerce(b)
ary[0].should be_kind_of(Bignum)
ary[1].should be_kind_of(Bignum)
ary[0].should be_kind_of(Integer)
ary[1].should be_kind_of(Integer)
ary.should == [b, a]
end
it "raises a TypeError when not passed a Fixnum or Bignum" do
it "raises a TypeError when not passed an Integer" do
a = bignum_value
-> { a.coerce(nil) }.should raise_error(TypeError)

View file

@ -27,7 +27,7 @@ describe "Integer#<=>" do
end
context "bignum" do
describe "with a Fixnum" do
describe "with an Integer" do
it "returns -1 when other is larger" do
(-bignum_value <=> 2).should == -1
end
@ -37,7 +37,7 @@ describe "Integer#<=>" do
end
end
describe "with a Bignum" do
describe "with an Integer" do
describe "when other is negative" do
it "returns -1 when self is negative and other is larger" do
(-bignum_value(42) <=> -bignum_value).should == -1
@ -116,7 +116,7 @@ describe "Integer#<=>" do
describe "with an Object" do
before :each do
@big = bignum_value
@num = mock("value for Bignum#<=>")
@num = mock("value for Integer#<=>")
end
it "calls #coerce on other" do
@ -158,7 +158,7 @@ describe "Integer#<=>" do
end
# The tests below are taken from matz's revision 23730 for Ruby trunk
it "returns 1 when self is Infinity and other is a Bignum" do
it "returns 1 when self is Infinity and other is an Integer" do
(infinity_value <=> Float::MAX.to_i*2).should == 1
end

View file

@ -1,5 +1,6 @@
require_relative '../../spec_helper'
ruby_version_is ""..."3.0" do
describe "Fixnum" do
it "is unified into Integer" do
suppress_warning do
@ -23,3 +24,4 @@ describe "Bignum" do
-> { Bignum }.should complain(/constant ::Bignum is deprecated/)
end
end
end

View file

@ -7,7 +7,7 @@ describe "Integer#denominator" do
@numbers = [
20, # Integer
-2709, # Negative Integer
99999999**99, # Bignum
99999999**99, # Integer
-99999**621, # Negative BigNum
0,
1

View file

@ -36,7 +36,7 @@ describe "Integer#div" do
10.div(y).should == result
end
it "coerces self and the given argument to Floats and returns self divided by other as Fixnum" do
it "coerces self and the given argument to Floats and returns self divided by other as Integer" do
1.div(0.2).should == 5
1.div(0.16).should == 6
1.div(0.169).should == 5

View file

@ -1,6 +1,6 @@
require_relative '../../spec_helper'
describe "Integer#downto [stop] when self and stop are Fixnums" do
describe "Integer#downto [stop] when self and stop are Integers" do
it "does not yield when stop is greater than self" do
result = []
5.downto(6) { |x| result << x }

View file

@ -68,14 +68,14 @@ describe "Integer#[]" do
-> { 3[obj] }.should raise_error(TypeError)
end
it "calls #to_int to coerce a String to a Bignum and returns 0" do
it "calls #to_int to coerce a String to an Integer and returns 0" do
obj = mock('bignum value')
obj.should_receive(:to_int).and_return(bignum_value)
3[obj].should == 0
end
it "returns 0 when passed a Float in the range of a Bignum" do
it "returns 0 when passed a Float in the range of an Integer" do
3[bignum_value.to_f].should == 0
end

View file

@ -2,7 +2,7 @@ require_relative '../../spec_helper'
describe "Integer#even?" do
context "fixnum" do
it "returns true for a Fixnum when it is an even number" do
it "returns true for an Integer when it is an even number" do
(-2).even?.should be_true
(-1).even?.should be_false
@ -11,7 +11,7 @@ describe "Integer#even?" do
2.even?.should be_true
end
it "returns true for a Bignum when it is an even number" do
it "returns true for an Integer when it is an even number" do
bignum_value(0).even?.should be_true
bignum_value(1).even?.should be_false

View file

@ -31,15 +31,15 @@ describe "Integer#gcd" do
-100.gcd(-100).should == 100
end
it "accepts a Bignum argument" do
it "accepts an Integer argument" do
bignum = 9999**99
bignum.should be_kind_of(Bignum)
bignum.should be_kind_of(Integer)
99.gcd(bignum).should == 99
end
it "works if self is a Bignum" do
it "works if self is an Integer" do
bignum = 9999**99
bignum.should be_kind_of(Bignum)
bignum.should be_kind_of(Integer)
bignum.gcd(99).should == 99
end

View file

@ -26,15 +26,15 @@ describe "Integer#gcdlcm" do
200.gcdlcm(20)[1].should == 200.lcm(20)
end
it "accepts a Bignum argument" do
it "accepts an Integer argument" do
bignum = 91999**99
bignum.should be_kind_of(Bignum)
bignum.should be_kind_of(Integer)
99.gcdlcm(bignum).should == [99.gcd(bignum), 99.lcm(bignum)]
end
it "works if self is a Bignum" do
it "works if self is an Integer" do
bignum = 9999**89
bignum.should be_kind_of(Bignum)
bignum.should be_kind_of(Integer)
bignum.gcdlcm(99).should == [bignum.gcd(99), bignum.lcm(99)]
end

View file

@ -31,15 +31,15 @@ describe "Integer#lcm" do
-100.lcm(-100).should == 100
end
it "accepts a Bignum argument" do
it "accepts an Integer argument" do
bignum = 9999**99
bignum.should be_kind_of(Bignum)
bignum.should be_kind_of(Integer)
99.lcm(bignum).should == bignum
end
it "works if self is a Bignum" do
it "works if self is an Integer" do
bignum = 9999**99
bignum.should be_kind_of(Bignum)
bignum.should be_kind_of(Integer)
bignum.lcm(99).should == bignum
end

View file

@ -52,19 +52,19 @@ describe "Integer#<< (with n << m)" do
(-7 << -64).should == -1
end
it "returns 0 when m < 0 and m is a Bignum" do
it "returns 0 when m < 0 and m is an Integer" do
(3 << -bignum_value).should == 0
end
it "returns an Bignum == fixnum_max * 2 when fixnum_max << 1 and n > 0" do
it "returns an Integer == fixnum_max * 2 when fixnum_max << 1 and n > 0" do
result = fixnum_max << 1
result.should be_an_instance_of(Bignum)
result.should be_an_instance_of(Integer)
result.should == fixnum_max * 2
end
it "returns an Bignum == fixnum_min * 2 when fixnum_min << 1 and n < 0" do
it "returns an Integer == fixnum_min * 2 when fixnum_min << 1 and n < 0" do
result = fixnum_min << 1
result.should be_an_instance_of(Bignum)
result.should be_an_instance_of(Integer)
result.should == fixnum_min * 2
end
@ -127,19 +127,19 @@ describe "Integer#<< (with n << m)" do
(@bignum << -68).should == 0
end
it "returns 0 when m < 0 and m is a Bignum" do
it "returns 0 when m < 0 and m is an Integer" do
(@bignum << -bignum_value).should == 0
end
it "returns a Fixnum == fixnum_max when (fixnum_max * 2) << -1 and n > 0" do
it "returns an Integer == fixnum_max when (fixnum_max * 2) << -1 and n > 0" do
result = (fixnum_max * 2) << -1
result.should be_an_instance_of(Fixnum)
result.should be_an_instance_of(Integer)
result.should == fixnum_max
end
it "returns a Fixnum == fixnum_min when (fixnum_min * 2) << -1 and n < 0" do
it "returns an Integer == fixnum_min when (fixnum_min * 2) << -1 and n < 0" do
result = (fixnum_min * 2) << -1
result.should be_an_instance_of(Fixnum)
result.should be_an_instance_of(Integer)
result.should == fixnum_min
end

View file

@ -56,15 +56,15 @@ describe "Integer#>> (with n >> m)" do
(3 >> bignum_value).should == 0
end
it "returns an Bignum == fixnum_max * 2 when fixnum_max >> -1 and n > 0" do
it "returns an Integer == fixnum_max * 2 when fixnum_max >> -1 and n > 0" do
result = fixnum_max >> -1
result.should be_an_instance_of(Bignum)
result.should be_an_instance_of(Integer)
result.should == fixnum_max * 2
end
it "returns an Bignum == fixnum_min * 2 when fixnum_min >> -1 and n < 0" do
it "returns an Integer == fixnum_min * 2 when fixnum_min >> -1 and n < 0" do
result = fixnum_min >> -1
result.should be_an_instance_of(Bignum)
result.should be_an_instance_of(Integer)
result.should == fixnum_min * 2
end
@ -153,19 +153,19 @@ describe "Integer#>> (with n >> m)" do
(@bignum >> 68).should == 0
end
it "returns 0 when m is a Bignum" do
it "returns 0 when m is an Integer" do
(@bignum >> bignum_value).should == 0
end
it "returns a Fixnum == fixnum_max when (fixnum_max * 2) >> 1 and n > 0" do
it "returns an Integer == fixnum_max when (fixnum_max * 2) >> 1 and n > 0" do
result = (fixnum_max * 2) >> 1
result.should be_an_instance_of(Fixnum)
result.should be_an_instance_of(Integer)
result.should == fixnum_max
end
it "returns a Fixnum == fixnum_min when (fixnum_min * 2) >> 1 and n < 0" do
it "returns an Integer == fixnum_min when (fixnum_min * 2) >> 1 and n < 0" do
result = (fixnum_min * 2) >> 1
result.should be_an_instance_of(Fixnum)
result.should be_an_instance_of(Integer)
result.should == fixnum_min
end

View file

@ -4,7 +4,7 @@ describe :integer_equal, shared: true do
1.send(@method, 1).should == true
9.send(@method, 5).should == false
# Actually, these call Float#==, Bignum#== etc.
# Actually, these call Float#==, Integer#== etc.
9.send(@method, 9.0).should == true
9.send(@method, 9.01).should == false

View file

@ -1,25 +1,25 @@
describe :integer_next, shared: true do
it "returns the next larger positive Fixnum" do
it "returns the next larger positive Integer" do
2.send(@method).should == 3
end
it "returns the next larger negative Fixnum" do
it "returns the next larger negative Integer" do
(-2).send(@method).should == -1
end
it "returns the next larger positive Bignum" do
it "returns the next larger positive Integer" do
bignum_value.send(@method).should == bignum_value(1)
end
it "returns the next larger negative Bignum" do
it "returns the next larger negative Integer" do
(-bignum_value(1)).send(@method).should == -bignum_value
end
it "overflows a Fixnum to a Bignum" do
it "overflows an Integer to an Integer" do
fixnum_max.send(@method).should == fixnum_max + 1
end
it "underflows a Bignum to a Fixnum" do
it "underflows an Integer to an Integer" do
(fixnum_min - 1).send(@method).should == fixnum_min
end
end

View file

@ -13,9 +13,9 @@ describe "Integer#to_r" do
298.to_r.denominator.should == 1
end
it "works even if self is a Bignum" do
it "works even if self is an Integer" do
bignum = 99999**999
bignum.should be_an_instance_of(Bignum)
bignum.should be_an_instance_of(Integer)
bignum.to_r.should == Rational(bignum, 1)
end

View file

@ -10,7 +10,7 @@ describe "Integer#-@" do
-8.send(:-@).should == 8
end
it "negates self at Fixnum/Bignum boundaries" do
it "negates self at Integer/Integer boundaries" do
(-fixnum_max).should == (0 - fixnum_max)
(-fixnum_max).should < 0
(-fixnum_min).should == (0 - fixnum_min)

View file

@ -1,6 +1,6 @@
require_relative '../../spec_helper'
describe "Integer#upto [stop] when self and stop are Fixnums" do
describe "Integer#upto [stop] when self and stop are Integers" do
it "does not yield when stop is less than self" do
result = []
5.upto(4) { |x| result << x }

View file

@ -13,7 +13,7 @@ describe "IO#initialize" do
rm_r @name
end
it "reassociates the IO instance with the new descriptor when passed a Fixnum" do
it "reassociates the IO instance with the new descriptor when passed an Integer" do
fd = new_fd @name, "r:utf-8"
@io.send :initialize, fd, 'r'
@io.fileno.should == fd

View file

@ -18,7 +18,7 @@ describe :io_new, shared: true do
rm_r @name
end
it "creates an IO instance from a Fixnum argument" do
it "creates an IO instance from an Integer argument" do
@io = IO.send(@method, @fd, "w")
@io.should be_an_instance_of(IO)
end
@ -55,7 +55,7 @@ describe :io_new, shared: true do
end
end
it "calls #to_int on an object to convert to a Fixnum" do
it "calls #to_int on an object to convert to an Integer" do
obj = mock("file descriptor")
obj.should_receive(:to_int).and_return(@fd)
@io = IO.send(@method, obj, "w")

View file

@ -60,7 +60,7 @@ describe :io_set_pos, shared: true do
end
end
it "does not accept Bignums that don't fit in a C long" do
it "does not accept Integers that don't fit in a C long" do
File.open @fname do |io|
-> { io.send @method, 2**128 }.should raise_error(RangeError)
end

View file

@ -54,7 +54,7 @@ describe :io_readlines_options_19, shared: true do
(result ? result : ScratchPad.recorded).should == IOSpecs.lines_space_separator
end
describe "when the object is a Fixnum" do
describe "when the object is an Integer" do
before :each do
@sep = $/
end
@ -69,7 +69,7 @@ describe :io_readlines_options_19, shared: true do
(result ? result : ScratchPad.recorded).should == IOSpecs.lines_space_separator_limit
end
it "uses the object as a limit if it is a Fixnum" do
it "uses the object as a limit if it is an Integer" do
result = IO.send(@method, @name, 10, &@object)
(result ? result : ScratchPad.recorded).should == IOSpecs.lines_limit
end
@ -96,7 +96,7 @@ describe :io_readlines_options_19, shared: true do
end
describe "when passed name, object, object" do
describe "when the first object is a Fixnum" do
describe "when the first object is an Integer" do
it "uses the second object as an options Hash" do
-> do
IO.send(@method, @filename, 10, mode: "w", &@object)
@ -113,7 +113,7 @@ describe :io_readlines_options_19, shared: true do
end
describe "when the first object is a String" do
it "uses the second object as a limit if it is a Fixnum" do
it "uses the second object as a limit if it is an Integer" do
result = IO.send(@method, @name, " ", 10, &@object)
(result ? result : ScratchPad.recorded).should == IOSpecs.lines_space_separator_limit
end
@ -140,7 +140,7 @@ describe :io_readlines_options_19, shared: true do
end
end
describe "when the first object is not a String or Fixnum" do
describe "when the first object is not a String or Integer" do
it "calls #to_str to convert the object to a String" do
sep = mock("io readlines separator")
sep.should_receive(:to_str).at_least(1).and_return(" ")
@ -148,7 +148,7 @@ describe :io_readlines_options_19, shared: true do
(result ? result : ScratchPad.recorded).should == IOSpecs.lines_space_separator_limit
end
it "uses the second object as a limit if it is a Fixnum" do
it "uses the second object as a limit if it is an Integer" do
result = IO.send(@method, @name, " ", 10, mode: "r", &@object)
(result ? result : ScratchPad.recorded).should == IOSpecs.lines_space_separator_limit
end

View file

@ -13,7 +13,7 @@ describe "IO.sysopen" do
it "returns the file descriptor for a given path" do
@fd = IO.sysopen(@filename, "w")
@fd.should be_kind_of(Fixnum)
@fd.should be_kind_of(Integer)
@fd.should_not equal(0)
end
@ -21,7 +21,7 @@ describe "IO.sysopen" do
platform_is_not :windows do
it "works on directories" do
@fd = IO.sysopen(tmp("")) # /tmp
@fd.should be_kind_of(Fixnum)
@fd.should be_kind_of(Integer)
@fd.should_not equal(0)
end
end

View file

@ -37,12 +37,12 @@ describe "IO#ungetbyte" do
end
ruby_version_is ''...'2.6' do
it "puts back one byte for a Fixnum argument..." do
it "puts back one byte for an Integer argument..." do
@io.ungetbyte(4095).should be_nil
@io.getbyte.should == 255
end
it "... but not for Bignum argument (eh?)" do
it "... but not for Integer argument (eh?)" do
-> {
@io.ungetbyte(0x4f7574206f6620636861722072616e6765)
}.should raise_error(TypeError)

View file

@ -9,7 +9,7 @@ describe :kernel_float, shared: true do
float2.should equal float
end
it "returns a Float for Fixnums" do
it "returns a Float for Integers" do
@object.send(:Float, 1).should == 1.0
end
@ -17,7 +17,7 @@ describe :kernel_float, shared: true do
@object.send(:Float, Complex(1)).should == 1.0
end
it "returns a Float for Bignums" do
it "returns a Float for Integers" do
@object.send(:Float, 1000000000000).should == 1000000000000.0
end

View file

@ -2,11 +2,11 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes'
describe :kernel_integer, shared: true do
it "returns a Bignum for a Bignum" do
it "returns an Integer for an Integer" do
Integer(2e100).should == 2e100
end
it "returns a Fixnum for a Fixnum" do
it "returns an Integer for an Integer" do
Integer(100).should == 100
end
@ -39,9 +39,9 @@ describe :kernel_integer, shared: true do
-> { Integer(nil) }.should raise_error(TypeError)
end
it "returns a Fixnum or Bignum object" do
Integer(2).should be_an_instance_of(Fixnum)
Integer(9**99).should be_an_instance_of(Bignum)
it "returns an Integer or Integer object" do
Integer(2).should be_an_instance_of(Integer)
Integer(9**99).should be_an_instance_of(Integer)
end
it "truncates Floats" do
@ -54,14 +54,14 @@ describe :kernel_integer, shared: true do
Integer(3.quo(2)).should == 1
end
it "returns the value of to_int if the result is a Fixnum" do
it "returns the value of to_int if the result is an Integer" do
obj = mock("object")
obj.should_receive(:to_int).and_return(1)
obj.should_not_receive(:to_i)
Integer(obj).should == 1
end
it "returns the value of to_int if the result is a Bignum" do
it "returns the value of to_int if the result is an Integer" do
obj = mock("object")
obj.should_receive(:to_int).and_return(2 * 10**100)
obj.should_not_receive(:to_i)

View file

@ -5,7 +5,7 @@ describe "Kernel#class" do
it "returns the class of the object" do
Object.new.class.should equal(Object)
1.class.should equal(Fixnum)
1.class.should equal(Integer)
3.14.class.should equal(Float)
:hello.class.should equal(Symbol)
"hello".class.should equal(String)

View file

@ -92,7 +92,7 @@ describe "Kernel#instance_variable_get when passed String" do
end
end
describe "Kernel#instance_variable_get when passed Fixnum" do
describe "Kernel#instance_variable_get when passed Integer" do
before :each do
@obj = Object.new
@obj.instance_variable_set("@test", :test)

View file

@ -31,7 +31,7 @@ describe "Kernel#instance_variable_set" do
-> { dog_at.new.instance_variable_set(:"@", "cat") }.should raise_error(NameError)
end
it "raises a TypeError if the instance variable name is a Fixnum" do
it "raises a TypeError if the instance variable name is an Integer" do
-> { "".instance_variable_set(1, 2) }.should raise_error(TypeError)
end

View file

@ -60,7 +60,7 @@ describe :kernel_require_basic, shared: true do
-> { @object.send(@method, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if passed a Fixnum" do
it "raises a TypeError if passed an Integer" do
-> { @object.send(@method, 42) }.should raise_error(TypeError)
end

View file

@ -17,7 +17,7 @@ describe "Kernel#singleton_class" do
false.singleton_class.should == FalseClass
end
it "raises TypeError for Fixnum" do
it "raises TypeError for Integer" do
-> { 123.singleton_class }.should raise_error(TypeError)
end

View file

@ -14,7 +14,7 @@ describe "Kernel#sleep" do
sleep(0.001).should >= 0
end
it "accepts a Fixnum" do
it "accepts an Integer" do
sleep(0).should >= 0
end

View file

@ -37,7 +37,7 @@ describe "Kernel.srand" do
srand.should == -17
end
it "accepts a Bignum as a seed" do
it "accepts an Integer as a seed" do
srand(0x12345678901234567890)
srand.should == 0x12345678901234567890
end

View file

@ -37,7 +37,7 @@ describe "Kernel#taint" do
v.should_not.tainted?
end
it "no raises error on fixnum values" do
it "no raises error on integer values" do
[1].each do |v|
-> { v.taint }.should_not raise_error(RuntimeError)
v.should_not.tainted?

View file

@ -15,8 +15,8 @@ describe "Marshal.dump" do
Marshal.dump(false).should == "\004\bF"
end
describe "with a Fixnum" do
it "dumps a Fixnum" do
describe "with an Integer" do
it "dumps an Integer" do
[ [Marshal, 0, "\004\bi\000"],
[Marshal, 5, "\004\bi\n"],
[Marshal, 8, "\004\bi\r"],
@ -38,11 +38,11 @@ describe "Marshal.dump" do
end
platform_is wordsize: 64 do
it "dumps a positive Fixnum > 31 bits as a Bignum" do
it "dumps a positive Integer > 31 bits as an Integer" do
Marshal.dump(2**31 + 1).should == "\x04\bl+\a\x01\x00\x00\x80"
end
it "dumps a negative Fixnum > 31 bits as a Bignum" do
it "dumps a negative Integer > 31 bits as an Integer" do
Marshal.dump(-2**31 - 1).should == "\x04\bl-\a\x01\x00\x00\x80"
end
end
@ -157,14 +157,14 @@ describe "Marshal.dump" do
end
end
describe "with a Bignum" do
it "dumps a Bignum" do
describe "with an Integer" do
it "dumps an Integer" do
[ [Marshal, -4611686018427387903, "\004\bl-\t\377\377\377\377\377\377\377?"],
[Marshal, -2361183241434822606847, "\004\bl-\n\377\377\377\377\377\377\377\377\177\000"],
].should be_computed_by(:dump)
end
it "dumps a Bignum" do
it "dumps an Integer" do
[ [Marshal, 2**64, "\004\bl+\n\000\000\000\000\000\000\000\000\001\000"],
[Marshal, 2**90, "\004\bl+\v#{"\000" * 11}\004"],
[Marshal, -2**63, "\004\bl-\t\000\000\000\000\000\000\000\200"],

View file

@ -227,36 +227,36 @@ module MarshalSpec
"\004\b:\010big"],
"Symbol big" => [('big' * 100).to_sym,
"\004\b:\002,\001#{'big' * 100}"],
"Bignum -2**64" => [-2**64,
"Integer -2**64" => [-2**64,
"\004\bl-\n\000\000\000\000\000\000\000\000\001\000"],
"Bignum -2**63" => [-2**63,
"Integer -2**63" => [-2**63,
"\004\bl-\t\000\000\000\000\000\000\000\200"],
"Fixnum -2**24" => [-2**24,
"Integer -2**24" => [-2**24,
"\004\bi\375\000\000\000"],
"Fixnum -4516727" => [-4516727,
"Integer -4516727" => [-4516727,
"\004\bi\375\211\024\273"],
"Fixnum -2**16" => [-2**16,
"Integer -2**16" => [-2**16,
"\004\bi\376\000\000"],
"Fixnum -2**8" => [-2**8,
"Integer -2**8" => [-2**8,
"\004\bi\377\000"],
"Fixnum -123" => [-123,
"Integer -123" => [-123,
"\004\bi\200"],
"Fixnum -124" => [-124, "\004\bi\377\204"],
"Fixnum 0" => [0,
"Integer -124" => [-124, "\004\bi\377\204"],
"Integer 0" => [0,
"\004\bi\000"],
"Fixnum 5" => [5,
"Integer 5" => [5,
"\004\bi\n"],
"Fixnum 122" => [122, "\004\bi\177"],
"Fixnum 123" => [123, "\004\bi\001{"],
"Fixnum 2**8" => [2**8,
"Integer 122" => [122, "\004\bi\177"],
"Integer 123" => [123, "\004\bi\001{"],
"Integer 2**8" => [2**8,
"\004\bi\002\000\001"],
"Fixnum 2**16" => [2**16,
"Integer 2**16" => [2**16,
"\004\bi\003\000\000\001"],
"Fixnum 2**24" => [2**24,
"Integer 2**24" => [2**24,
"\004\bi\004\000\000\000\001"],
"Bignum 2**64" => [2**64,
"Integer 2**64" => [2**64,
"\004\bl+\n\000\000\000\000\000\000\000\000\001\000"],
"Bignum 2**90" => [2**90,
"Integer 2**90" => [2**90,
"\004\bl+\v#{"\000" * 11}\004"],
"Class String" => [String,
"\004\bc\vString"],
@ -334,31 +334,31 @@ module MarshalSpec
"\004\b:\010big"],
"Symbol big" => [('big' * 100).to_sym,
"\004\b:\002,\001#{'big' * 100}"],
"Bignum -2**64" => [-2**64,
"Integer -2**64" => [-2**64,
"\004\bl-\n\000\000\000\000\000\000\000\000\001\000"],
"Bignum -2**63" => [-2**63,
"Integer -2**63" => [-2**63,
"\004\bl-\t\000\000\000\000\000\000\000\200"],
"Fixnum -2**24" => [-2**24,
"Integer -2**24" => [-2**24,
"\004\bi\375\000\000\000"],
"Fixnum -2**16" => [-2**16,
"Integer -2**16" => [-2**16,
"\004\bi\376\000\000"],
"Fixnum -2**8" => [-2**8,
"Integer -2**8" => [-2**8,
"\004\bi\377\000"],
"Fixnum -123" => [-123,
"Integer -123" => [-123,
"\004\bi\200"],
"Fixnum 0" => [0,
"Integer 0" => [0,
"\004\bi\000"],
"Fixnum 5" => [5,
"Integer 5" => [5,
"\004\bi\n"],
"Fixnum 2**8" => [2**8,
"Integer 2**8" => [2**8,
"\004\bi\002\000\001"],
"Fixnum 2**16" => [2**16,
"Integer 2**16" => [2**16,
"\004\bi\003\000\000\001"],
"Fixnum 2**24" => [2**24,
"Integer 2**24" => [2**24,
"\004\bi\004\000\000\000\001"],
"Bignum 2**64" => [2**64,
"Integer 2**64" => [2**64,
"\004\bl+\n\000\000\000\000\000\000\000\000\001\000"],
"Bignum 2**90" => [2**90,
"Integer 2**90" => [2**90,
"\004\bl+\v#{"\000" * 11}\004"],
"Class String" => [String,
"\004\bc\vString"],

View file

@ -211,14 +211,14 @@ describe :marshal_load, shared: true do
y.first.tainted?.should be_false
end
it "does not taint Fixnums" do
it "does not taint Integers" do
x = [1]
y = Marshal.send(@method, Marshal.dump(x).taint)
y.tainted?.should be_true
y.first.tainted?.should be_false
end
it "does not taint Bignums" do
it "does not taint Integers" do
x = [bignum_value]
y = Marshal.send(@method, Marshal.dump(x).taint)
y.tainted?.should be_true
@ -740,19 +740,19 @@ describe :marshal_load, shared: true do
end
end
describe "for a Bignum" do
describe "for an Integer" do
platform_is wordsize: 64 do
context "that is Bignum on 32-bit platforms but Fixnum on 64-bit" do
it "dumps a Fixnum" do
context "that is Integer on 32-bit platforms but Integer on 64-bit" do
it "dumps an Integer" do
val = Marshal.send(@method, "\004\bl+\ab:wU")
val.should == 1433877090
val.class.should == Fixnum
val.class.should == Integer
end
it "dumps an array containing multiple references to the Bignum as an array of Fixnum" do
it "dumps an array containing multiple references to the Integer as an array of Integer" do
arr = Marshal.send(@method, "\004\b[\al+\a\223BwU@\006")
arr.should == [1433879187, 1433879187]
arr.each { |v| v.class.should == Fixnum }
arr.each { |v| v.class.should == Integer }
end
end
end

View file

@ -16,9 +16,9 @@ describe "Method#source_location" do
file.should == File.realpath('../fixtures/classes.rb', __FILE__)
end
it "sets the last value to a Fixnum representing the line on which the method was defined" do
it "sets the last value to an Integer representing the line on which the method was defined" do
line = @method.source_location.last
line.should be_an_instance_of(Fixnum)
line.should be_an_instance_of(Integer)
line.should == 5
end

View file

@ -85,17 +85,17 @@ describe "Module#attr_accessor" do
describe "on immediates" do
before :each do
class Fixnum
class Integer
attr_accessor :foobar
end
end
after :each do
if Fixnum.method_defined?(:foobar)
Fixnum.send(:remove_method, :foobar)
if Integer.method_defined?(:foobar)
Integer.send(:remove_method, :foobar)
end
if Fixnum.method_defined?(:foobar=)
Fixnum.send(:remove_method, :foobar=)
if Integer.method_defined?(:foobar=)
Integer.send(:remove_method, :foobar=)
end
end

View file

@ -13,9 +13,9 @@ describe "Module.constants" do
it "returns an array of Symbol names" do
# This in NOT an exhaustive list
Module.constants.should include(:Array, :Bignum, :Class, :Comparable, :Dir,
Module.constants.should include(:Array, :Class, :Comparable, :Dir,
:Enumerable, :ENV, :Exception, :FalseClass,
:File, :Fixnum, :Float, :Hash, :Integer, :IO,
:File, :Float, :Hash, :Integer, :IO,
:Kernel, :Math, :Method, :Module, :NilClass,
:Numeric, :Object, :Range, :Regexp, :String,
:Symbol, :Thread, :Time, :TrueClass)

View file

@ -31,7 +31,7 @@ describe "Module#private_method_defined?" do
ModuleSpecs::CountsMixin.private_method_defined?(:private_3).should == true
end
it "raises a TypeError if passed a Fixnum" do
it "raises a TypeError if passed an Integer" do
-> do
ModuleSpecs::CountsMixin.private_method_defined?(1)
end.should raise_error(TypeError)

View file

@ -31,7 +31,7 @@ describe "Module#protected_method_defined?" do
ModuleSpecs::CountsMixin.protected_method_defined?(:protected_3).should == true
end
it "raises a TypeError if passed a Fixnum" do
it "raises a TypeError if passed an Integer" do
-> do
ModuleSpecs::CountsMixin.protected_method_defined?(1)
end.should raise_error(TypeError)

View file

@ -31,7 +31,7 @@ describe "Module#public_method_defined?" do
ModuleSpecs::CountsMixin.public_method_defined?(:public_3).should == true
end
it "raises a TypeError if passed a Fixnum" do
it "raises a TypeError if passed an Integer" do
-> do
ModuleSpecs::CountsMixin.public_method_defined?(1)
end.should raise_error(TypeError)

View file

@ -5,7 +5,7 @@ describe "NilClass#to_i" do
nil.to_i.should == 0
end
it "does not cause NilClass to be coerced to Fixnum" do
it "does not cause NilClass to be coerced to Integer" do
(0 == nil).should == false
end
end

View file

@ -6,7 +6,7 @@ describe "Numeric#denominator" do
before :each do
@numbers = [
20, # Integer
99999999**99, # Bignum
99999999**99, # Integer
]
end

View file

@ -11,7 +11,7 @@ describe "Numeric#quo" do
2.quo(2.5).should eql(0.8)
end
it "returns the result of self divided by the given Bignum as a Float" do
it "returns the result of self divided by the given Integer as a Float" do
45.quo(bignum_value).should be_close(1.04773789668636e-08, TOLERANCE)
end

View file

@ -7,7 +7,7 @@ describe "Numeric#real" do
20, # Integer
398.72, # Float
Rational(3, 4), # Rational
bignum_value, # Bignum
bignum_value, # Integer
infinity_value,
nan_value
].map{ |n| [n, -n] }.flatten

View file

@ -6,7 +6,7 @@ describe :numeric_imag, shared: true do
20, # Integer
398.72, # Float
Rational(3, 4), # Rational
bignum_value, # Bignum
bignum_value, # Integer
infinity_value,
nan_value
].map{|n| [n,-n]}.flatten

View file

@ -6,7 +6,7 @@ describe :numeric_rect, shared: true do
20, # Integer
398.72, # Float
Rational(3, 4), # Rational
99999999**99, # Bignum
99999999**99, # Integer
infinity_value,
nan_value
]

View file

@ -24,9 +24,9 @@ describe :numeric_step, :shared => true do
1.0.step.first(5).should == [1.0, 2.0, 3.0, 4.0, 5.0]
end
describe "when self, stop and step are Fixnums" do
it "yields only Fixnums" do
@step.call(1, 5, 1) { |x| x.should be_an_instance_of(Fixnum) }
describe "when self, stop and step are Integers" do
it "yields only Integers" do
@step.call(1, 5, 1) { |x| x.should be_an_instance_of(Integer) }
end
describe "with a positive step" do
@ -224,7 +224,7 @@ describe :numeric_step, :shared => true do
end
describe "when step is a String" do
describe "with self and stop as Fixnums" do
describe "with self and stop as Integers" do
it "raises an ArgumentError when step is a numeric representation" do
-> { @step.call(1, 5, "1") {} }.should raise_error(ArgumentError)
-> { @step.call(1, 5, "0.1") {} }.should raise_error(ArgumentError)
@ -280,7 +280,7 @@ describe :numeric_step, :shared => true do
end
describe "when step is a String" do
describe "with self and stop as Fixnums" do
describe "with self and stop as Integers" do
it "returns an Enumerator" do
@step.call(1, 5, "foo").should be_an_instance_of(Enumerator)
end
@ -296,7 +296,7 @@ describe :numeric_step, :shared => true do
describe "returned Enumerator" do
describe "size" do
describe "when step is a String" do
describe "with self and stop as Fixnums" do
describe "with self and stop as Integers" do
it "raises an ArgumentError when step is a numeric representation" do
-> { @step.call(1, 5, "1").size }.should raise_error(ArgumentError)
-> { @step.call(1, 5, "0.1").size }.should raise_error(ArgumentError)
@ -319,7 +319,7 @@ describe :numeric_step, :shared => true do
end
end
describe "when self, stop and step are Fixnums and step is positive" do
describe "when self, stop and step are Integers and step is positive" do
it "returns the difference between self and stop divided by the number of steps" do
@step.call(5, 10, 11).size.should == 1
@step.call(5, 10, 6).size.should == 1
@ -336,7 +336,7 @@ describe :numeric_step, :shared => true do
end
end
describe "when self, stop and step are Fixnums and step is negative" do
describe "when self, stop and step are Integers and step is negative" do
it "returns the difference between self and stop divided by the number of steps" do
@step.call(10, 5, -11).size.should == 1
@step.call(10, 5, -6).size.should == 1

View file

@ -7,7 +7,7 @@ describe "ObjectSpace._id2ref" do
r.should == s
end
it "retrieves a Fixnum by object_id" do
it "retrieves an Integer by object_id" do
f = 1
r = ObjectSpace._id2ref(f.object_id)
r.should == f

View file

@ -7,7 +7,7 @@ describe "Proc#hash" do
end
it "returns an Integer" do
proc { 1 + 489 }.hash.should be_kind_of(Fixnum)
proc { 1 + 489 }.hash.should be_kind_of(Integer)
end
it "is stable" do

View file

@ -34,21 +34,21 @@ describe "Proc#source_location" do
file.should == File.realpath('../fixtures/source_location.rb', __FILE__)
end
it "sets the last value to a Fixnum representing the line on which the proc was defined" do
it "sets the last value to an Integer representing the line on which the proc was defined" do
line = @proc.source_location.last
line.should be_an_instance_of(Fixnum)
line.should be_an_instance_of(Integer)
line.should == 4
line = @proc_new.source_location.last
line.should be_an_instance_of(Fixnum)
line.should be_an_instance_of(Integer)
line.should == 12
line = @lambda.source_location.last
line.should be_an_instance_of(Fixnum)
line.should be_an_instance_of(Integer)
line.should == 8
line = @method.source_location.last
line.should be_an_instance_of(Fixnum)
line.should be_an_instance_of(Integer)
line.should == 15
end

View file

@ -2,7 +2,7 @@ require_relative '../../spec_helper'
describe "Process.euid" do
it "returns the effective user ID for this process" do
Process.euid.should be_kind_of(Fixnum)
Process.euid.should be_kind_of(Integer)
end
it "also goes by Process::UID.eid" do

View file

@ -5,19 +5,19 @@ describe "Process.getpriority" do
it "coerces arguments to Integers" do
ret = Process.getpriority mock_int(Process::PRIO_PROCESS), mock_int(0)
ret.should be_kind_of(Fixnum)
ret.should be_kind_of(Integer)
end
it "gets the scheduling priority for a specified process" do
Process.getpriority(Process::PRIO_PROCESS, 0).should be_kind_of(Fixnum)
Process.getpriority(Process::PRIO_PROCESS, 0).should be_kind_of(Integer)
end
it "gets the scheduling priority for a specified process group" do
Process.getpriority(Process::PRIO_PGRP, 0).should be_kind_of(Fixnum)
Process.getpriority(Process::PRIO_PGRP, 0).should be_kind_of(Integer)
end
it "gets the scheduling priority for a specified user" do
Process.getpriority(Process::PRIO_USER, 0).should be_kind_of(Fixnum)
Process.getpriority(Process::PRIO_USER, 0).should be_kind_of(Integer)
end
end
end

View file

@ -16,7 +16,7 @@ describe "Process.kill" do
-> { Process.kill("term", @pid) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if signal is not a Fixnum or String" do
it "raises an ArgumentError if signal is not an Integer or String" do
signal = mock("process kill signal")
signal.should_not_receive(:to_int)

View file

@ -3,7 +3,7 @@ require_relative '../../spec_helper'
platform_is_not :windows do
describe "Process.maxgroups" do
it "returns the maximum number of gids allowed in the supplemental group access list" do
Process.maxgroups.should be_kind_of(Fixnum)
Process.maxgroups.should be_kind_of(Integer)
end
it "sets the maximum number of gids allowed in the supplemental group access list" do

View file

@ -3,7 +3,7 @@ require_relative '../../spec_helper'
describe "Process.pid" do
it "returns the process id of this process" do
pid = Process.pid
pid.should be_kind_of(Fixnum)
pid.should be_kind_of(Integer)
Process.pid.should == pid
end
end

View file

@ -48,10 +48,10 @@ describe "Process.spawn" do
-> { Process.wait Process.spawn("echo spawn") }.should output_to_fd("spawn\n")
end
it "returns the process ID of the new process as a Fixnum" do
it "returns the process ID of the new process as an Integer" do
pid = Process.spawn(*ruby_exe, "-e", "exit")
Process.wait pid
pid.should be_an_instance_of(Fixnum)
pid.should be_an_instance_of(Integer)
end
it "returns immediately" do
@ -457,7 +457,7 @@ describe "Process.spawn" do
# redirection
it "redirects STDOUT to the given file descriptor if out: Fixnum" do
it "redirects STDOUT to the given file descriptor if out: Integer" do
File.open(@name, 'w') do |file|
-> do
Process.wait Process.spawn("echo glark", out: file.fileno)
@ -483,7 +483,7 @@ describe "Process.spawn" do
File.read(@name).should == "glark\n"
end
it "redirects STDERR to the given file descriptor if err: Fixnum" do
it "redirects STDERR to the given file descriptor if err: Integer" do
File.open(@name, 'w') do |file|
-> do
Process.wait Process.spawn("echo glark>&2", err: file.fileno)

View file

@ -1,8 +1,8 @@
require_relative '../../spec_helper'
describe "Random.new_seed" do
it "returns a Bignum" do
Random.new_seed.should be_an_instance_of(Bignum)
it "returns an Integer" do
Random.new_seed.should be_an_instance_of(Integer)
end
it "returns an arbitrary seed value each time" do

View file

@ -4,7 +4,7 @@ describe "Random.new" do
end
it "uses a random seed value if none is supplied" do
Random.new.seed.should be_an_instance_of(Bignum)
Random.new.seed.should be_an_instance_of(Integer)
end
it "returns Random instances initialized with different seeds" do

View file

@ -49,18 +49,18 @@ describe "Random.rand" do
end
end
describe "Random#rand with Fixnum" do
describe "Random#rand with Integer" do
it "returns an Integer" do
Random.new.rand(20).should be_an_instance_of(Fixnum)
Random.new.rand(20).should be_an_instance_of(Integer)
end
it "returns a Fixnum greater than or equal to 0" do
it "returns an Integer greater than or equal to 0" do
prng = Random.new
ints = 20.times.map { prng.rand(5) }
ints.min.should >= 0
end
it "returns a Fixnum less than the argument" do
it "returns an Integer less than the argument" do
prng = Random.new
ints = 20.times.map { prng.rand(5) }
ints.max.should <= 4
@ -92,19 +92,19 @@ describe "Random#rand with Fixnum" do
end
end
describe "Random#rand with Bignum" do
it "typically returns a Bignum" do
describe "Random#rand with Integer" do
it "typically returns an Integer" do
rnd = Random.new(1)
10.times.map{ rnd.rand(bignum_value*2) }.max.should be_an_instance_of(Bignum)
10.times.map{ rnd.rand(bignum_value*2) }.max.should be_an_instance_of(Integer)
end
it "returns a Bignum greater than or equal to 0" do
it "returns an Integer greater than or equal to 0" do
prng = Random.new
bigs = 20.times.map { prng.rand(bignum_value) }
bigs.min.should >= 0
end
it "returns a Bignum less than the argument" do
it "returns an Integer less than the argument" do
prng = Random.new
bigs = 20.times.map { prng.rand(bignum_value) }
bigs.max.should < bignum_value
@ -159,7 +159,7 @@ end
describe "Random#rand with Range" do
it "returns an element from the Range" do
Random.new.rand(20..43).should be_an_instance_of(Fixnum)
Random.new.rand(20..43).should be_an_instance_of(Integer)
end
it "supports custom object types" do

View file

@ -14,11 +14,11 @@ describe "Range#hash" do
(0..10).hash.should_not == (0...10).hash
end
it "generates a Fixnum for the hash value" do
(0..0).hash.should be_an_instance_of(Fixnum)
(0..1).hash.should be_an_instance_of(Fixnum)
(0...10).hash.should be_an_instance_of(Fixnum)
(0..10).hash.should be_an_instance_of(Fixnum)
it "generates an Integer for the hash value" do
(0..0).hash.should be_an_instance_of(Integer)
(0..1).hash.should be_an_instance_of(Integer)
(0...10).hash.should be_an_instance_of(Integer)
(0..10).hash.should be_an_instance_of(Integer)
end
end

Some files were not shown because too many files have changed in this diff Show more