1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-04-27 18:53:23 +02:00
parent 00c33d9c23
commit a1b4816759
193 changed files with 3026 additions and 3387 deletions
spec/ruby
.travis.ymlCONTRIBUTING.mdREADME.md
command_line
core
array
basicobject
comparable
complex
dir
enumerable
enumerator/lazy
env
false
fiber
file
float
hash
integer
io
kernel
matchdata
math
method
module
nil
numeric
objectspace
proc
process
rational
regexp
string

View file

@ -3,20 +3,18 @@ language: ruby
install:
- git clone https://github.com/ruby/mspec.git ../mspec
script:
- ../mspec/bin/mspec $MSPEC_OPTS
- CHECK_LEAKS=true ../mspec/bin/mspec
matrix:
include:
- name: Running each spec twice
rvm: 2.5.5
script:
- CHECK_LEAKS=true ../mspec/bin/mspec -R2 -ff
- rvm: 2.4.6
- rvm: 2.5.5
env: MSPEC_OPTS="-R2 -ff"
- rvm: 2.3.8
- rvm: 2.4.5
env: CHECK_LEAKS=true
- rvm: 2.5.5
env: CHECK_LEAKS=true
- rvm: 2.6.2
env: CHECK_LEAKS=true
- env: RUBOCOP=true
rvm: 2.4.5
- rvm: 2.6.3
- name: RuboCop Lint Checks
rvm: 2.4.6
script:
- gem install rubocop:0.61.0
- rubocop

View file

@ -144,11 +144,11 @@ end
# Combining guards
guard -> { platform_is :windows and ruby_version_is ""..."2.3" } do
# Windows and RUBY_VERSION < 2.3
guard -> { platform_is :windows and ruby_version_is ""..."2.5" } do
# Windows and RUBY_VERSION < 2.5
end
guard_not -> { platform_is :windows and ruby_version_is ""..."2.3" } do
guard_not -> { platform_is :windows and ruby_version_is ""..."2.5" } do
# The opposite
end

View file

@ -28,8 +28,8 @@ ruby/spec is known to be tested in these implementations for every commit:
* [TruffleRuby](https://github.com/oracle/truffleruby/tree/master/spec/ruby)
* [Opal](https://github.com/opal/opal/tree/master/spec)
ruby/spec describes the behavior of Ruby 2.3 and more recent Ruby versions.
More precisely, every latest stable MRI release should [pass](https://travis-ci.org/ruby/spec) all specs of ruby/spec (2.3.x, 2.4.x, 2.5.x, 2.6.x, etc), and those are tested in TravisCI.
ruby/spec describes the behavior of Ruby 2.4 and more recent Ruby versions.
More precisely, every latest stable MRI release should [pass](https://travis-ci.org/ruby/spec) all specs of ruby/spec (2.4.x, 2.5.x, 2.6.x, etc), and those are tested in TravisCI.
The specs are synchronized both ways around once a month by @eregon between ruby/spec, MRI, JRuby and TruffleRuby.
Each of these repositories has a full copy of the specs under `spec/ruby` to ease editing specs.
@ -49,6 +49,7 @@ For older specs try these commits:
* Ruby 2.0.0-p647 - [Suite](https://github.com/ruby/spec/commit/245862558761d5abc676843ef74f86c9bcc8ea8d) using [MSpec](https://github.com/ruby/mspec/commit/f90efa068791064f955de7a843e96e2d7d3041c2) (may encounter 2 failures)
* Ruby 2.1.9 - [Suite](https://github.com/ruby/spec/commit/f029e65241374386077ac500add557ae65069b55) using [MSpec](https://github.com/ruby/mspec/commit/55568ea3918c6380e64db8c567d732fa5781efed)
* Ruby 2.2.10 - [Suite](https://github.com/ruby/spec/commit/cbaa0e412270c944df0c2532fc500c920dba0e92) using [MSpec](https://github.com/ruby/mspec/commit/d84d7668449e96856c5f6bac8cb1526b6d357ce3)
* Ruby 2.3.8 - [Suite](https://github.com/ruby/spec/commit/dc733114d8ae66a3368ba3a98422c50147a76ba5) using [MSpec](https://github.com/ruby/mspec/commit/4599bc195fb109f2a482a01c32a7d659518369ea)
### Running the specs

View file

@ -37,15 +37,6 @@ describe "The --enable and --disable flags" do
ruby_exe("p 'foo'.frozen?", options: "--disable-frozen-string-literal").chomp.should == "false"
end
ruby_version_is "2.6" do
it "can be used with jit" do
ruby_exe("p :OK", options: "--enable=jit 2>&1").chomp.should == ":OK"
ruby_exe("p :OK", options: "--disable=jit 2>&1").chomp.should == ":OK"
ruby_exe("p :OK", options: "--enable-jit 2>&1").chomp.should == ":OK"
ruby_exe("p :OK", options: "--disable-jit 2>&1").chomp.should == ":OK"
end
end
it "can be used with all" do
e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]"
env = {'RUBYOPT' => '-w'}

View file

@ -110,7 +110,6 @@ describe "Array#concat" do
ary.concat([5, 6]).should == [4, 5, 6]
end
ruby_version_is "2.4" do
it "takes multiple arguments" do
ary = [1, 2]
ary.concat [3, 4]
@ -129,4 +128,3 @@ describe "Array#concat" do
ary.should == [1, 2]
end
end
end

View file

@ -1,11 +1,9 @@
require_relative '../../spec_helper'
describe "Array#max" do
ruby_version_is "2.4" do
it "is defined on Array" do
[1].method(:max).owner.should equal Array
end
end
it "returns nil with no values" do
[].max.should == nil

View file

@ -1,11 +1,9 @@
require_relative '../../spec_helper'
describe "Array#min" do
ruby_version_is "2.4" do
it "is defined on Array" do
[1].method(:max).owner.should equal Array
end
end
it "returns nil with no values" do
[].min.should == nil

View file

@ -2,7 +2,6 @@
require_relative '../../../spec_helper'
ruby_version_is '2.4' do
describe "Array#pack with :buffer option" do
it "returns specified buffer" do
n = [ 65, 66, 67 ]
@ -49,4 +48,3 @@ ruby_version_is '2.4' do
end
end
end
end

View file

@ -121,7 +121,6 @@ describe "Array#reject!" do
a.should == [1, 2, 3]
end
ruby_version_is "2.4" do
it "only removes elements for which the block returns true, keeping the element which raised an error." do
a = [1, 2, 3, 4]
begin
@ -137,7 +136,6 @@ describe "Array#reject!" do
a.should == [1, 3, 4]
end
end
it_behaves_like :enumeratorize, :reject!
it_behaves_like :enumeratorized_with_origin_size, :reject!, [1,2,3]

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
ruby_version_is '2.4' do
describe "Array#sum" do
it "returns the sum of elements" do
[1, 2, 3].sum.should == 6
@ -41,4 +40,3 @@ ruby_version_is '2.4' do
[b].sum(a).should == 42
end
end
end

View file

@ -19,8 +19,12 @@ describe "BasicObject" do
BasicObjectSpecs::BOSubclass.kernel_defined?.should be_nil
end
it "is included in Object's list of constants" do
Object.constants(false).should include(:BasicObject)
end
it "includes itself in its list of constants" do
BasicObject.constants.should include(:BasicObject)
BasicObject.constants(false).should include(:BasicObject)
end
end

View file

@ -1,7 +1,6 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
ruby_version_is '2.4' do
describe 'Comparable#clamp' do
it 'raises an Argument error unless given 2 parameters' do
c = ComparableSpecs::Weird.new(0)
@ -47,4 +46,3 @@ ruby_version_is '2.4' do
c.clamp(one, two).should equal(two)
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
ruby_version_is "2.4" do
describe "Complex#finite?" do
it "returns true if magnitude is finite" do
(1+1i).finite?.should == true
@ -26,11 +25,8 @@ ruby_version_is "2.4" do
value.finite?.should == false
end
ruby_bug "#14014", "2.4"..."2.5" do
it "returns false for NaN" do
value = Complex(Float::NAN, Float::NAN)
value.finite?.should == false
end
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
ruby_version_is "2.4" do
describe "Complex#infinite?" do
it "returns nil if magnitude is finite" do
(1+1i).infinite?.should == nil
@ -31,4 +30,3 @@ ruby_version_is "2.4" do
value.should == nil
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
ruby_version_is "2.4" do
describe "Dir.empty?" do
before :all do
@empty_dir = tmp("empty_dir")
@ -30,4 +29,3 @@ ruby_version_is "2.4" do
lambda { Dir.empty? tmp("nonexistent") }.should raise_error(Errno::ENOENT)
end
end
end

View file

@ -6,22 +6,12 @@ describe "Enumerable#chunk" do
ScratchPad.record []
end
ruby_version_is ""..."2.4" do
it "raises an ArgumentError if called without a block" do
lambda do
EnumerableSpecs::Numerous.new.chunk
end.should raise_error(ArgumentError)
end
end
ruby_version_is "2.4" do
it "returns an Enumerator if called without a block" do
chunk = EnumerableSpecs::Numerous.new(1, 2, 3, 1, 2).chunk
chunk.should be_an_instance_of(Enumerator)
result = chunk.with_index {|elt, i| elt - i }.to_a
result.should == [[1, [1, 2, 3]], [-2, [1, 2]]]
end
end
it "returns an Enumerator if given a block" do
EnumerableSpecs::Numerous.new.chunk {}.should be_an_instance_of(Enumerator)

View file

@ -1,7 +1,6 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
ruby_version_is '2.4' do
describe 'Enumerable#sum' do
before :each do
@enum = Object.new.to_enum
@ -27,4 +26,3 @@ ruby_version_is '2.4' do
@enum.sum { |element| element * 2 }.should == 10/3r
end
end
end

View file

@ -1,7 +1,6 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
ruby_version_is '2.4' do
describe 'Enumerable#uniq' do
it 'returns an array that contains only unique elements' do
[0, 1, 2, 3].to_enum.uniq { |n| n.even? }.should == [0, 1]
@ -84,11 +83,8 @@ ruby_version_is '2.4' do
end
end
ruby_bug '#13669', ''...'2.5' do
it 'returns all yield arguments as an array' do
@enum.uniq { |_, label| label.downcase }.should == [[0, 'foo'], [2, 'bar']]
end
end
end
end
end

View file

@ -25,15 +25,6 @@ describe "Enumerator::Lazy#chunk" do
Enumerator::Lazy.new(Object.new, 100) {}.chunk { |v| v }.size.should == nil
end
ruby_version_is ""..."2.4" do
it "raises an ArgumentError if called without a block" do
lambda do
@yieldsmixed.chunk
end.should raise_error(ArgumentError)
end
end
ruby_version_is "2.4" do
it "returns an Enumerator if called without a block" do
chunk = @yieldsmixed.chunk
chunk.should be_an_instance_of(Enumerator::Lazy)
@ -41,7 +32,6 @@ describe "Enumerator::Lazy#chunk" do
res = chunk.each { |v| true }.force
res.should == [[true, EnumeratorLazySpecs::YieldsMixed.gathered_yields]]
end
end
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
it "stops after specified times" do

View file

@ -14,9 +14,7 @@ describe "Enumerator::Lazy" do
:select, :slice_after, :slice_before, :slice_when, :take, :take_while,
:to_enum, :zip
]
ruby_version_is "2.4" do
lazy_methods += [:chunk_while, :uniq]
end
Enumerator::Lazy.instance_methods(false).should include(*lazy_methods)
end

View file

@ -5,4 +5,43 @@ require_relative 'shared/select'
describe "Enumerator::Lazy#select" do
it_behaves_like :enumerator_lazy_select, :select
it "doesn't pre-evaluate the next element" do
eval_count = 0
enum = %w[Text1 Text2 Text3].lazy.select do
eval_count += 1
true
end
eval_count.should == 0
enum.next
eval_count.should == 1
end
it "doesn't over-evaluate when peeked" do
eval_count = 0
enum = %w[Text1 Text2 Text3].lazy.select do
eval_count += 1
true
end
eval_count.should == 0
enum.peek
enum.peek
eval_count.should == 1
end
it "doesn't re-evaluate after peek" do
eval_count = 0
enum = %w[Text1 Text2 Text3].lazy.select do
eval_count += 1
true
end
eval_count.should == 0
enum.peek
eval_count.should == 1
enum.next
eval_count.should == 1
end
end

View file

@ -1,7 +1,6 @@
require_relative '../../../spec_helper'
require_relative 'fixtures/classes'
ruby_version_is '2.4' do
describe 'Enumerator::Lazy#uniq' do
context 'without block' do
before :each do
@ -13,12 +12,10 @@ ruby_version_is '2.4' do
@lazy.force.should == [0, 1]
end
ruby_bug "#14495", "2.4"..."2.5.2" do
it 'return same value after rewind' do
@lazy.force.should == [0, 1]
@lazy.force.should == [0, 1]
end
end
it 'sets the size to nil' do
@lazy.size.should == nil
@ -35,12 +32,10 @@ ruby_version_is '2.4' do
@lazy.force.should == [0, 1]
end
ruby_bug "#14495", "2.4"..."2.5.2" do
it 'return same value after rewind' do
@lazy.force.should == [0, 1]
@lazy.force.should == [0, 1]
end
end
it 'sets the size to nil' do
@lazy.size.should == nil
@ -60,13 +55,11 @@ ruby_version_is '2.4' do
@lazy = enum.lazy
end
ruby_bug "#14495", "2.4"..."2.5.2" do
it 'return same value after rewind' do
enum = @lazy.uniq { |_, label| label.downcase }
enum.force.should == [[0, 'foo'], [2, 'bar']]
enum.force.should == [[0, 'foo'], [2, 'bar']]
end
end
it 'returns all yield arguments as an array' do
@lazy.uniq { |_, label| label.downcase }.force.should == [[0, 'foo'], [2, 'bar']]
@ -79,4 +72,3 @@ ruby_version_is '2.4' do
s.first(100).uniq
end
end
end

View file

@ -14,6 +14,12 @@ describe "ENV.fetch" do
context "when the key is not found" do
it_behaves_like :key_error, ->(obj, key) { obj.fetch(key) }, ENV
it "formats the object with #inspect in the KeyError message" do
-> {
ENV.fetch('foo')
}.should raise_error(KeyError, 'key not found: "foo"')
end
end
it "provides the given default parameter" do

View file

@ -1,9 +1,7 @@
require_relative '../../spec_helper'
ruby_version_is '2.4' do
describe "FalseClass#dup" do
it "returns self" do
false.dup.should equal(false)
end
end
end

View file

@ -42,7 +42,7 @@ with_feature :fiber do
f.resume
# When we execute the second #resume call, the ensure block DOES exit,
# the ensure clause runs. This is Ruby behavior as of 2.3.1.
# the ensure clause runs.
f.resume
exit 0

View file

@ -2,7 +2,6 @@ require_relative '../../spec_helper'
require_relative '../../shared/file/zero'
describe "File.empty?" do
ruby_version_is "2.4" do
it_behaves_like :file_zero, :empty?, File
it_behaves_like :file_zero_missing, :empty?, File
@ -12,4 +11,3 @@ describe "File.empty?" do
end
end
end
end

View file

@ -222,16 +222,14 @@ platform_is_not :windows do
ENV["HOME"] = @home
end
ruby_version_is ''...'2.4' do
it "raises an ArgumentError when passed '~' if HOME is nil" do
it "uses the user database when passed '~' if HOME is nil" do
ENV.delete "HOME"
lambda { File.expand_path("~") }.should raise_error(ArgumentError)
File.directory?(File.expand_path("~")).should == true
end
it "raises an ArgumentError when passed '~/' if HOME is nil" do
it "uses the user database when passed '~/' if HOME is nil" do
ENV.delete "HOME"
lambda { File.expand_path("~/") }.should raise_error(ArgumentError)
end
File.directory?(File.expand_path("~/")).should == true
end
it "raises an ArgumentError when passed '~' if HOME == ''" do

View file

@ -12,7 +12,7 @@ describe "File.mtime" do
it "returns the modification Time of the file" do
File.mtime(@filename).should be_kind_of(Time)
File.mtime(@filename).should be_close(@mtime, 60.0)
File.mtime(@filename).should be_close(@mtime, TIME_TOLERANCE)
end
guard -> { platform_is :linux or (platform_is :windows and ruby_version_is '2.5') } do

View file

@ -9,13 +9,11 @@ describe "File::Stat#dev_major" do
rm_r @name
end
ruby_version_is "2.4" do
platform_is_not :windows do
it "returns the major part of File::Stat#dev" do
File.stat(@name).dev_major.should be_kind_of(Integer)
end
end
end
platform_is :windows do
it "returns nil" do

View file

@ -9,13 +9,11 @@ describe "File::Stat#dev_minor" do
rm_r @name
end
ruby_version_is "2.4" do
platform_is_not :windows do
it "returns the minor part of File::Stat#dev" do
File.stat(@name).dev_minor.should be_kind_of(Integer)
end
end
end
platform_is :windows do
it "returns nil" do

View file

@ -17,13 +17,11 @@ describe "File::Stat#rdev_major" do
end
end
ruby_version_is "2.4" do
platform_is_not :windows do
it "returns the major part of File::Stat#rdev" do
File.stat(@name).rdev_major.should be_kind_of(Integer)
end
end
end
platform_is :windows do
it "returns nil" do

View file

@ -17,13 +17,11 @@ describe "File::Stat#rdev_minor" do
end
end
ruby_version_is "2.4" do
platform_is_not :windows do
it "returns the minor part of File::Stat#rdev" do
File.stat(@name).rdev_minor.should be_kind_of(Integer)
end
end
end
platform_is :windows do
it "returns nil" do

View file

@ -27,10 +27,10 @@ describe "File.utime" do
File.atime(@file2).should be_close(@atime, 0.0001)
File.mtime(@file2).should be_close(@mtime, 0.0001)
else
File.atime(@file1).to_i.should be_close(@atime.to_i, 2)
File.mtime(@file1).to_i.should be_close(@mtime.to_i, 2)
File.atime(@file2).to_i.should be_close(@atime.to_i, 2)
File.mtime(@file2).to_i.should be_close(@mtime.to_i, 2)
File.atime(@file1).to_i.should be_close(@atime.to_i, TIME_TOLERANCE)
File.mtime(@file1).to_i.should be_close(@mtime.to_i, TIME_TOLERANCE)
File.atime(@file2).to_i.should be_close(@atime.to_i, TIME_TOLERANCE)
File.mtime(@file2).to_i.should be_close(@mtime.to_i, TIME_TOLERANCE)
end
end
@ -43,10 +43,10 @@ describe "File.utime" do
File.atime(@file2).should be_close(tn, 0.050)
File.mtime(@file2).should be_close(tn, 0.050)
else
File.atime(@file1).to_i.should be_close(Time.now.to_i, 2)
File.mtime(@file1).to_i.should be_close(Time.now.to_i, 2)
File.atime(@file2).to_i.should be_close(Time.now.to_i, 2)
File.mtime(@file2).to_i.should be_close(Time.now.to_i, 2)
File.atime(@file1).to_i.should be_close(Time.now.to_i, TIME_TOLERANCE)
File.mtime(@file1).to_i.should be_close(Time.now.to_i, TIME_TOLERANCE)
File.atime(@file2).to_i.should be_close(Time.now.to_i, TIME_TOLERANCE)
File.mtime(@file2).to_i.should be_close(Time.now.to_i, TIME_TOLERANCE)
end
end
@ -63,10 +63,10 @@ describe "File.utime" do
File.mtime(@file2).should be_close(@mtime, 0.0001)
else
File.utime(@atime.to_i, @mtime.to_i, @file1, @file2)
File.atime(@file1).to_i.should be_close(@atime.to_i, 2)
File.mtime(@file1).to_i.should be_close(@mtime.to_i, 2)
File.atime(@file2).to_i.should be_close(@atime.to_i, 2)
File.mtime(@file2).to_i.should be_close(@mtime.to_i, 2)
File.atime(@file1).to_i.should be_close(@atime.to_i, TIME_TOLERANCE)
File.mtime(@file1).to_i.should be_close(@mtime.to_i, TIME_TOLERANCE)
File.atime(@file2).to_i.should be_close(@atime.to_i, TIME_TOLERANCE)
File.mtime(@file2).to_i.should be_close(@mtime.to_i, TIME_TOLERANCE)
end
end

View file

@ -11,7 +11,6 @@ describe "Float#ceil" do
+9223372036854775808.1.ceil.should eql(+9223372036854775808)
end
ruby_version_is "2.4" do
it "returns the smallest number greater than or equal to self with an optionally given precision" do
2.1679.ceil(0).should eql(3)
214.94.ceil(-1).should eql(220)
@ -20,4 +19,3 @@ describe "Float#ceil" do
5.123812.ceil(4).should eql(5.1239)
end
end
end

View file

@ -1,10 +1,8 @@
require_relative '../../spec_helper'
ruby_version_is '2.4' do
describe "Float#dup" do
it "returns self" do
float = 2.4
float.dup.should equal(float)
end
end
end

View file

@ -11,7 +11,6 @@ describe "Float#floor" do
+9223372036854775808.1.floor.should eql(+9223372036854775808)
end
ruby_version_is "2.4" do
it "returns the largest number less than or equal to self with an optionally given precision" do
2.1679.floor(0).should eql(2)
214.94.floor(-1).should eql(210)
@ -20,4 +19,3 @@ describe "Float#floor" do
5.123812.floor(4).should eql(5.1238)
end
end
end

View file

@ -83,17 +83,35 @@ describe "Float#round" do
-2.4e200.round(-200).should eql( -2 * 10 ** 200 )
end
ruby_version_is "2.4" do
it "returns different rounded values depending on the half option" do
2.5.round(half: nil).should eql(3)
2.5.round(half: :up).should eql(3)
2.5.round(half: :down).should eql(2)
2.5.round(half: :even).should eql(2)
3.5.round(half: nil).should eql(4)
3.5.round(half: :up).should eql(4)
3.5.round(half: :down).should eql(3)
3.5.round(half: :even).should eql(4)
(-2.5).round(half: nil).should eql(-3)
(-2.5).round(half: :up).should eql(-3)
(-2.5).round(half: :down).should eql(-2)
(-2.5).round(half: :even).should eql(-2)
end
it "rounds self to an optionally given precision with a half option" do
5.55.round(1, half: nil).should eql(5.6)
5.55.round(1, half: :up).should eql(5.6)
5.55.round(1, half: :down).should eql(5.5)
5.55.round(1, half: :even).should eql(5.6)
end
it "raises FloatDomainError for exceptional values with a half option" do
lambda { (+infinity_value).round(half: :up) }.should raise_error(FloatDomainError)
lambda { (-infinity_value).round(half: :down) }.should raise_error(FloatDomainError)
lambda { nan_value.round(half: :even) }.should raise_error(FloatDomainError)
end
it "raise for a non-existent round mode" do
lambda { 14.2.round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense")
end
end

View file

@ -4,7 +4,6 @@ require_relative 'shared/to_i'
describe "Float#truncate" do
it_behaves_like :float_to_i, :truncate
ruby_version_is "2.4" do
it "returns self truncated to an optionally given precision" do
2.1679.truncate(0).should eql(2)
7.1.truncate(1).should eql(7.1)
@ -13,4 +12,3 @@ describe "Float#truncate" do
5.123812.truncate(4).should eql(5.1238)
end
end
end

View file

@ -1,7 +1,6 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
ruby_version_is "2.4" do
describe "Hash#compact" do
before :each do
@hash = { truthy: true, false: false, nil: nil, nil => true }
@ -58,4 +57,3 @@ ruby_version_is "2.4" do
end
end
end
end

View file

@ -108,7 +108,6 @@ describe "Hash#compare_by_identity" do
@idh.keys.first.should equal foo
end
ruby_bug "#12855", ""..."2.4.1" do
it "gives different identity for string literals" do
@idh['foo'] = 1
@idh['foo'] = 2
@ -116,7 +115,6 @@ describe "Hash#compare_by_identity" do
@idh.size.should == 2
end
end
end
describe "Hash#compare_by_identity?" do
it "returns false by default" do

View file

@ -8,6 +8,12 @@ describe "Hash#fetch" do
it_behaves_like :key_error, ->(obj, key) { obj.fetch(key) }, {}
it_behaves_like :key_error, ->(obj, key) { obj.fetch(key) }, Hash.new { 5 }
it_behaves_like :key_error, ->(obj, key) { obj.fetch(key) }, Hash.new(5)
it "formats the object with #inspect in the KeyError message" do
-> {
{}.fetch('foo')
}.should raise_error(KeyError, 'key not found: "foo"')
end
end
it "returns the value for key" do

View file

@ -69,9 +69,12 @@ describe "Hash#merge" do
result.should == { a: 1, b: 2, c: 3, d: 4 }
end
it "accepts zero arguments and returns self" do
it "accepts zero arguments and returns a copy of self" do
hash = { a: 1 }
hash.merge.should eql(hash)
merged = hash.merge
merged.should eql(hash)
merged.should_not equal(hash)
end
end
end

View file

@ -21,7 +21,7 @@ describe :hash_each, shared: true do
ary.sort.should == ["a", "b", "c"]
end
it "yields 2 values and not an Array of 2 elements" do
it "yields 2 values and not an Array of 2 elements when given a callable of arity 2" do
obj = Object.new
def obj.foo(key, value)
ScratchPad << key << value

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
ruby_version_is "2.4" do
describe "Hash#transform_values" do
before :each do
@hash = { a: 1, b: 2, c: 3 }
@ -96,4 +95,3 @@ ruby_version_is "2.4" do
end
end
end
end

View file

@ -6,7 +6,6 @@ describe "Integer#ceil" do
it_behaves_like :integer_to_i, :ceil
it_behaves_like :integer_rounding_positive_precision, :ceil
ruby_version_is "2.4" do
context "precision argument specified as part of the ceil method is negative" do
it "returns the smallest integer greater than self with at least precision.abs trailing zeros" do
18.ceil(-1).should eql(20)
@ -18,4 +17,3 @@ describe "Integer#ceil" do
end
end
end
end

View file

@ -68,19 +68,6 @@ describe "Integer#coerce" do
lambda { a.coerce(:test) }.should raise_error(TypeError)
end
ruby_version_is ""..."2.4" do
it "raises a TypeError when passed a String" do
a = bignum_value
lambda { a.coerce("123") }.should raise_error(TypeError)
end
it "raises a TypeError when passed a Float" do
a = bignum_value
lambda { a.coerce(12.3) }.should raise_error(TypeError)
end
end
ruby_version_is "2.4" do
it "coerces both values to Floats and returns [other, self] when passed a Float" do
a = bignum_value
a.coerce(1.2).should == [1.2, a.to_f]
@ -102,4 +89,3 @@ describe "Integer#coerce" do
end
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
ruby_version_is "2.4" do
describe "Integer#digits" do
it "returns an array of place values in base-10 by default" do
12345.digits.should == [5,4,3,2,1]
@ -31,4 +30,3 @@ ruby_version_is "2.4" do
lambda { -12345.digits(7) }.should raise_error(Math::DomainError)
end
end
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
ruby_version_is '2.4' do
describe "Integer#dup" do
it "returns self for small integers" do
integer = 1_000
@ -12,4 +11,3 @@ ruby_version_is '2.4' do
integer.dup.should equal(integer)
end
end
end

View file

@ -6,7 +6,6 @@ describe "Integer#floor" do
it_behaves_like :integer_to_i, :floor
it_behaves_like :integer_rounding_positive_precision, :floor
ruby_version_is "2.4" do
context "precision argument specified as part of the floor method is negative" do
it "returns the largest integer less than self with at least precision.abs trailing zeros" do
1832.floor(-1).should eql(1830)
@ -18,4 +17,3 @@ describe "Integer#floor" do
end
end
end
end

View file

@ -5,13 +5,11 @@ describe "Integer" do
Integer.include?(Comparable).should == true
end
ruby_version_is "2.4" do
it "is the class of both small and large integers" do
42.class.should equal(Integer)
bignum_value.class.should equal(Integer)
end
end
end
describe "Integer#integer?" do
it "returns true for Integers" do

View file

@ -16,14 +16,12 @@ ruby_version_is "2.5" do
2.pow(8, 15).should == 1
end
ruby_bug '#13669', '2.5'...'2.5.1' do
it "works well with bignums" do
2.pow(61, 5843009213693951).should eql 3697379018277258
2.pow(62, 5843009213693952).should eql 1551748822859776
2.pow(63, 5843009213693953).should eql 3103497645717974
2.pow(64, 5843009213693954).should eql 363986077738838
end
end
it "handles sign like #divmod does" do
2.pow(5, 12).should == 8

View file

@ -63,7 +63,6 @@ describe "Integer#round" do
lambda { 42.round(obj) }.should raise_error(TypeError)
end
ruby_version_is "2.4" do
it "returns different rounded values depending on the half option" do
25.round(-1, half: :up).should eql(30)
25.round(-1, half: :down).should eql(20)
@ -75,7 +74,6 @@ describe "Integer#round" do
(-25).round(-1, half: :down).should eql(-20)
(-25).round(-1, half: :even).should eql(-20)
end
end
ruby_version_is "2.4"..."2.5" do
it "returns itself as a float if passed a positive precision and the half option" do

View file

@ -5,13 +5,11 @@ describe :integer_rounding_positive_precision, shared: true do
end
end
ruby_version_is "2.4" do
it "returns self if passed a precision of zero" do
[2, -4, 10**70, -10**100].each do |v|
v.send(@method, 0).should eql(v)
end
end
end
ruby_version_is "2.4"..."2.5" do
it "returns itself as a float if passed a positive precision" do

View file

@ -6,7 +6,6 @@ describe "Integer#truncate" do
it_behaves_like :integer_to_i, :truncate
it_behaves_like :integer_rounding_positive_precision, :truncate
ruby_version_is "2.4" do
context "precision argument specified as part of the truncate method is negative" do
it "returns an integer with at least precision.abs trailing zeros" do
1832.truncate(-1).should eql(1830)
@ -18,4 +17,3 @@ describe "Integer#truncate" do
end
end
end
end

View file

@ -139,14 +139,12 @@ describe "IO#gets" do
end
end
ruby_version_is "2.4" do
describe "when passed chomp" do
it "returns the first line without a trailing newline character" do
@io.gets(chomp: true).should == IOSpecs.lines_without_newline_characters[0]
end
end
end
end
describe "IO#gets" do
before :each do

View file

@ -43,11 +43,9 @@ describe "IO#readline" do
end
end
ruby_version_is "2.4" do
describe "when passed chomp" do
it "returns the first line without a trailing newline character" do
@io.readline(chomp: true).should == IOSpecs.lines_without_newline_characters[0]
end
end
end
end

View file

@ -156,7 +156,6 @@ describe :io_each, shared: true do
end
end
ruby_version_is "2.4" do
describe "when passed chomp" do
it "yields each line without trailing newline characters to the passed block" do
@io.send(@method, chomp: true) { |s| ScratchPad << s }
@ -164,7 +163,6 @@ describe :io_each, shared: true do
end
end
end
end
describe :io_each_default_separator, shared: true do
before :each do

View file

@ -18,13 +18,11 @@ describe :io_readlines, shared: true do
(result ? result : ScratchPad.recorded).should == IOSpecs.lines_empty_separator
end
ruby_version_is "2.4" do
it "yields a sequence of lines without trailing newline characters when chomp is passed" do
result = IO.send(@method, @name, chomp: true, &@object)
(result ? result : ScratchPad.recorded).should == IOSpecs.lines_without_newline_characters
end
end
end
describe :io_readlines_options_19, shared: true do
before :each do

View file

@ -175,7 +175,6 @@ describe "Kernel.Complex()" do
end
end
ruby_bug "#15525", "2.6"..."2.6.1" do
describe "and nil arguments" do
it "swallows an error" do
Complex(nil, exception: false).should == nil
@ -186,4 +185,3 @@ describe "Kernel.Complex()" do
end
end
end
end

View file

@ -125,7 +125,6 @@ describe :kernel_integer, shared: true do
end
end
ruby_bug "#15525", "2.6"..."2.6.1" do
describe "and passed NaN" do
it "swallows an error" do
Integer(nan_value, exception: false).should == nil
@ -137,7 +136,6 @@ describe :kernel_integer, shared: true do
Integer(infinity_value, exception: false).should == nil
end
end
end
describe "and passed nil" do
it "swallows an error" do

View file

@ -37,7 +37,6 @@ describe "Kernel#clone" do
o3.frozen?.should == true
end
ruby_version_is '2.4' do
it 'takes an option to copy freeze state or not' do
@obj.clone(freeze: true).frozen?.should == false
@obj.clone(freeze: false).frozen?.should == false
@ -45,7 +44,6 @@ describe "Kernel#clone" do
@obj.clone(freeze: true).frozen?.should == true
@obj.clone(freeze: false).frozen?.should == false
end
end
it "copies instance variables" do
clone = @obj.clone

View file

@ -79,29 +79,6 @@ describe :kernel_dup_clone, shared: true do
o3.untrusted?.should == true
end
ruby_version_is ''...'2.4' do
it "raises a TypeError for NilClass" do
lambda { nil.send(@method) }.should raise_error(TypeError)
end
it "raises a TypeError for TrueClass" do
lambda { true.send(@method) }.should raise_error(TypeError)
end
it "raises a TypeError for FalseClass" do
lambda { false.send(@method) }.should raise_error(TypeError)
end
it "raises a TypeError for Fixnum" do
lambda { 1.send(@method) }.should raise_error(TypeError)
end
it "raises a TypeError for Symbol" do
lambda { :my_symbol.send(@method) }.should raise_error(TypeError)
end
end
ruby_version_is '2.4' do
it "returns nil for NilClass" do
nil.send(@method).should == nil
end
@ -121,7 +98,6 @@ describe :kernel_dup_clone, shared: true do
it "returns the same Symbol for Symbol" do
:my_symbol.send(@method).should == :my_symbol
end
end
ruby_version_is ''...'2.5' do
it "raises a TypeError for Complex" do

View file

@ -553,6 +553,15 @@ describe :kernel_require, shared: true do
required = ruby_exe(code, options: '--disable-gems')
required.should == "false\n" * provided.size
end
it "unicode_normalize is part of core and not $LOADED_FEATURES" do
features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
features.lines.each { |feature|
feature.should_not include("unicode_normalize")
}
-> { @object.require("unicode_normalize") }.should raise_error(LoadError)
end
end
end

View file

@ -101,12 +101,10 @@ describe "Kernel#warn" do
-> { w.f4("foo", 3) }.should output(nil, %r|core/kernel/fixtures/classes.rb:#{w.f3_call_lineno}: warning: foo|)
end
ruby_bug "#14846", "2.5"..."2.6" do
it "does not prepend caller information if line number is too big" do
w = KernelSpecs::WarnInNestedCall.new
-> { w.f4("foo", 100) }.should output(nil, "warning: foo\n")
end
end
it "prepends even if a message is empty or nil" do
w = KernelSpecs::WarnInNestedCall.new
@ -127,11 +125,9 @@ describe "Kernel#warn" do
-> { warn "", uplevel: -100 }.should raise_error(ArgumentError)
end
ruby_bug "#14846", "2.5"..."2.6" do
it "raises ArgumentError if passed -1" do
-> { warn "", uplevel: -1 }.should raise_error(ArgumentError)
end
end
it "raises TypeError if passed not Integer" do
-> { warn "", uplevel: "" }.should raise_error(TypeError)

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
ruby_version_is '2.4' do
describe 'MatchData#named_captures' do
it 'returns a Hash that has captured name and the matched string pairs' do
/(?<a>.)(?<b>.)?/.match('0').named_captures.should == { 'a' => '0', 'b' => nil }
@ -14,4 +13,3 @@ ruby_version_is '2.4' do
/\A(?<a>.)(?<b>.)(?<b>.)(?<a>.)?\z/.match('012').named_captures.should == { 'a' => '0', 'b' => '2' }
end
end
end

View file

@ -11,7 +11,6 @@ describe "MatchData#values_at" do
end
end
ruby_version_is '2.4' do
it 'slices captures with the given names' do
/(?<a>.)(?<b>.)(?<c>.)/.match('012').values_at(:c, :a).should == ['2', '0']
end
@ -20,4 +19,3 @@ describe "MatchData#values_at" do
/\A(?<a>.)(?<b>.)\z/.match('01').values_at(0, 1, 2, :a, :b).should == ['01', '0', '1', '0', '1']
end
end
end

View file

@ -11,11 +11,9 @@ describe "Math.lgamma" do
end
end
ruby_version_is "2.4" do
it "returns [Infinity, -1] when passed -0.0" do
Math.lgamma(-0.0).should == [infinity_value, -1]
end
end
it "returns [log(sqrt(PI)), 1] when passed 0.5" do
lg1 = Math.lgamma(0.5)

View file

@ -243,17 +243,19 @@ describe "Method#parameters" do
end
it "returns [[:rest]] for core methods with variable-length argument lists" do
m = "foo"
# delete! takes rest args
"foo".method(:delete!).parameters.should == [[:rest]]
end
# match takes rest args
m.method(:match).parameters.should == [[:rest]]
# [] takes 1 to 3 args
m.method(:[]).parameters.should == [[:rest]]
it "returns [[:rest]] or [[:opt]] for core methods with optional arguments" do
# pop takes 1 optional argument
[
[[:rest]],
[[:opt]]
].should include([].method(:pop).parameters)
end
it "returns [[:req]] for each parameter for core methods with fixed-length argument lists" do
m = "foo"
m.method(:+).parameters.should == [[:req]]
"foo".method(:+).parameters.should == [[:req]]
end
end

View file

@ -165,17 +165,6 @@ describe "Module#include" do
}.should raise_error(ArgumentError)
end
ruby_version_is ''...'2.4' do
it "accepts no-arguments" do
lambda {
Module.new do
include
end
}.should_not raise_error
end
end
ruby_version_is '2.4' do
it "doesn't accept no-arguments" do
lambda {
Module.new do
@ -183,7 +172,6 @@ describe "Module#include" do
end
}.should raise_error(ArgumentError)
end
end
it "returns the class it's included into" do
m = Module.new

View file

@ -231,17 +231,6 @@ describe "Module#prepend" do
}.should raise_error(ArgumentError)
end
ruby_version_is ''...'2.4' do
it "accepts no-arguments" do
lambda {
Module.new do
prepend
end
}.should_not raise_error
end
end
ruby_version_is '2.4' do
it "doesn't accept no-arguments" do
lambda {
Module.new do
@ -249,7 +238,6 @@ describe "Module#prepend" do
end
}.should raise_error(ArgumentError)
end
end
it "returns the class it's included into" do
m = Module.new

View file

@ -52,7 +52,6 @@ describe "Module#private" do
end.should raise_error(NameError)
end
ruby_bug "#14604", ""..."2.5.1" do
it "only makes the method private in the class it is called on" do
base = Class.new do
def wrapped
@ -92,4 +91,3 @@ describe "Module#private" do
klass.new.wrapped.should == 2
end
end
end

View file

@ -74,17 +74,6 @@ describe "Module#refine" do
end.should raise_error(TypeError)
end
ruby_version_is "" ... "2.4" do
it "raises TypeError if passed a module" do
lambda do
Module.new do
refine(Enumerable) {}
end
end.should raise_error(TypeError)
end
end
ruby_version_is "2.4" do
it "accepts a module as argument" do
inner_self = nil
Module.new do
@ -97,7 +86,6 @@ describe "Module#refine" do
inner_self.public_instance_methods.should include(:blah)
end
end
it "raises ArgumentError if not given a block" do
lambda do
@ -319,59 +307,6 @@ describe "Module#refine" do
end
context "for methods accessed indirectly" do
ruby_version_is "" ... "2.4" do
it "is not honored by Kernel#send" do
refinement = Module.new do
refine ModuleSpecs::ClassWithFoo do
def foo; "foo from refinement"; end
end
end
result = nil
Module.new do
using refinement
result = ModuleSpecs::ClassWithFoo.new.send :foo
end
result.should == "foo"
end
it "is not honored by BasicObject#__send__" do
refinement = Module.new do
refine ModuleSpecs::ClassWithFoo do
def foo; "foo from refinement"; end
end
end
result = nil
Module.new do
using refinement
result = ModuleSpecs::ClassWithFoo.new.__send__ :foo
end
result.should == "foo"
end
it "is not honored by Symbol#to_proc" do
refinement = Module.new do
refine Integer do
def to_s
"(#{super})"
end
end
end
result = nil
Module.new do
using refinement
result = [1, 2, 3].map(&:to_s)
end
result.should == ["1", "2", "3"]
end
end
ruby_version_is "2.4" do
it "is honored by Kernel#send" do
refinement = Module.new do
refine ModuleSpecs::ClassWithFoo do
@ -421,7 +356,6 @@ describe "Module#refine" do
result.should == ["(1)", "(2)", "(3)"]
end
end
ruby_version_is "" ... "2.6" do
it "is not honored by Kernel#public_send" do

View file

@ -1,9 +1,7 @@
require_relative '../../spec_helper'
ruby_version_is '2.4' do
describe "NilClass#dup" do
it "returns self" do
nil.dup.should equal(nil)
end
end
end

View file

@ -1,10 +1,8 @@
require_relative '../../spec_helper'
ruby_version_is "2.4" do
describe "Numeric#finite?" do
it "returns true by default" do
o = mock_numeric("finite")
o.finite?.should be_true
end
end
end

View file

@ -1,10 +1,8 @@
require_relative '../../spec_helper'
ruby_version_is "2.4" do
describe "Numeric#infinite?" do
it "returns nil by default" do
o = mock_numeric("infinite")
o.infinite?.should == nil
end
end
end

View file

@ -224,9 +224,6 @@ describe :numeric_step, :shared => true do
describe "when step is a String" do
error = nil
ruby_version_is ""..."2.4" do
error = ArgumentError
end
ruby_version_is "2.4"..."2.5" do
error = TypeError
end
@ -305,9 +302,6 @@ describe :numeric_step, :shared => true do
describe "size" do
describe "when step is a String" do
error = nil
ruby_version_is ""..."2.4" do
error = ArgumentError
end
ruby_version_is "2.4"..."2.5" do
error = TypeError
end

View file

@ -201,7 +201,6 @@ describe "ObjectSpace.each_object" do
expected = [ a, b, c, d ]
# singleton classes should be walked only on >= 2.3
expected << c_sclass
c_sclass.should be_kind_of(a.singleton_class)

View file

@ -17,7 +17,6 @@ describe "Proc#call on a Proc created with Kernel#lambda or Kernel#proc" do
it_behaves_like :proc_call_on_proc_or_lambda, :call
end
ruby_bug "#15118", ""..."2.6" do
describe "Proc#[] with frozen_string_literals" do
it "doesn't duplicate frozen strings" do
ProcArefSpecs.aref.frozen?.should be_false
@ -26,4 +25,3 @@ ruby_bug "#15118", ""..."2.6" do
ProcArefFrozenSpecs.aref_freeze.frozen?.should be_true
end
end
end

View file

@ -0,0 +1,55 @@
require_relative '../../spec_helper'
require_relative 'fixtures/clocks'
describe "Process.clock_getres" do
ProcessSpecs.clock_constants.each do |name, value|
it "matches the clock in practice for Process::#{name}" do
times = []
10_000.times do
times << Process.clock_gettime(value, :nanosecond)
end
reported = Process.clock_getres(value, :nanosecond)
# The clock should not be more accurate than reported (times should be
# a multiple of reported precision.)
times.select { |t| t % reported > 0 }.should be_empty
# We're assuming precision is a multiple of ten - it may or may not
# be an incompatibility if it isn't but we'd like to notice this,
# and the spec following these wouldn't work if it isn't.
reported.should > 0
(reported == 1 || reported % 10 == 0).should be_true
# The clock should not be less accurate than reported (times should
# not all be a multiple of the next precision up, assuming precisions
# are multiples of ten.)
times.select { |t| t % (reported * 10) == 0 }.size.should_not == times.size
end
end
# These are documented
it "with :GETTIMEOFDAY_BASED_CLOCK_REALTIME reports 1 microsecond" do
Process.clock_getres(:GETTIMEOFDAY_BASED_CLOCK_REALTIME, :nanosecond).should == 1_000
end
it "with :TIME_BASED_CLOCK_REALTIME reports 1 second" do
Process.clock_getres(:TIME_BASED_CLOCK_REALTIME, :nanosecond).should == 1_000_000_000
end
platform_is_not :windows do
it "with :GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID reports 1 microsecond" do
Process.clock_getres(:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID, :nanosecond).should == 1_000
end
end
# These are observed
it "with Process::CLOCK_REALTIME reports at least 1 microsecond" do
Process.clock_getres(Process::CLOCK_REALTIME, :nanosecond).should <= 1_000
end
it "with Process::CLOCK_MONOTONIC reports at least 1 microsecond" do
Process.clock_getres(Process::CLOCK_MONOTONIC, :nanosecond).should <= 1_000
end
end

View file

@ -1,20 +1,12 @@
require_relative '../../spec_helper'
require_relative 'fixtures/clocks'
describe "Process.clock_gettime" do
platform_is_not :windows, :solaris do
Process.constants.select { |c|
c.to_s.start_with?('CLOCK_') &&
# These require CAP_WAKE_ALARM and are not documented in clock_gettime(),
# they return EINVAL if the permission is not granted.
c != :CLOCK_BOOTTIME_ALARM &&
c != :CLOCK_REALTIME_ALARM
}.each do |c|
it "can be called with Process::#{c}" do
value = Process.const_get(c)
ProcessSpecs.clock_constants.each do |name, value|
it "can be called with Process::#{name}" do
Process.clock_gettime(value).should be_an_instance_of(Float)
end
end
end
describe 'time units' do
it 'handles a fixed set of time units' do
@ -36,7 +28,8 @@ describe "Process.clock_gettime" do
t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
t1.should be_an_instance_of(Float)
t2.should be_close(t1, 2.0) # 2.0 is chosen arbitrarily to allow for time skew without admitting failure cases, which would be off by an order of magnitude.
t2.should be_an_instance_of(Float)
t2.should be_close(t1, TIME_TOLERANCE)
end
it 'uses the default time unit (:float_second) when passed nil' do
@ -44,7 +37,8 @@ describe "Process.clock_gettime" do
t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second)
t1.should be_an_instance_of(Float)
t2.should be_close(t1, 2.0) # 2.0 is chosen arbitrarily to allow for time skew without admitting failure cases, which would be off by an order of magnitude.
t2.should be_an_instance_of(Float)
t2.should be_close(t1, TIME_TOLERANCE)
end
end
end

View file

@ -0,0 +1,24 @@
module ProcessSpecs
def self.clock_constants
clocks = []
platform_is_not :windows, :solaris do
clocks += Process.constants.select { |c| c.to_s.start_with?('CLOCK_') }
# These require CAP_WAKE_ALARM and are not documented in
# Process#clock_gettime they return EINVAL if the permission
# is not granted.
clocks -= [:CLOCK_BOOTTIME_ALARM, :CLOCK_REALTIME_ALARM]
# These clocks in practice on Linux do not seem to match
# their reported resolution.
clocks -= [:CLOCK_REALTIME_COARSE, :CLOCK_MONOTONIC_COARSE]
clocks.map! { |c|
[c, Process.const_get(c)]
}
end
clocks
end
end

View file

@ -13,10 +13,8 @@ describe "Process.wait2" do
end
leaked = Process.waitall
$stderr.puts "leaked before wait2 specs: #{leaked}" unless leaked.empty?
with_feature :mjit do
# Ruby-space should not see PIDs used by mjit
leaked.should be_empty
end
rescue Errno::ECHILD # No child processes
rescue NotImplementedError
end

View file

@ -8,10 +8,8 @@ describe "Process.wait" do
begin
leaked = Process.waitall
puts "leaked before wait specs: #{leaked}" unless leaked.empty?
with_feature :mjit do
# Ruby-space should not see PIDs used by mjit
leaked.should be_empty
end
rescue NotImplementedError
end
end

View file

@ -1,3 +1,4 @@
require_relative '../../spec_helper'
require_relative '../../shared/rational/round'
describe "Rational#round" do

View file

@ -111,7 +111,6 @@ describe "Regexp#match" do
end
end
ruby_version_is "2.4" do
describe "Regexp#match?" do
before :each do
# Resetting Regexp.last_match
@ -138,7 +137,6 @@ ruby_version_is "2.4" do
/./.match?(nil).should be_false
end
end
end
describe "Regexp#~" do
it "matches against the contents of $_" do

View file

@ -17,15 +17,6 @@ describe "String#capitalize" do
"hello".taint.capitalize.tainted?.should == true
end
ruby_version_is ''...'2.4' do
it "is locale insensitive (only upcases a-z and only downcases A-Z)" do
"ÄÖÜ".capitalize.should == "ÄÖÜ"
"ärger".capitalize.should == "ärger"
"BÄR".capitalize.should == "BÄr"
end
end
ruby_version_is '2.4' do
describe "full Unicode case mapping" do
it "works for all of Unicode with no option" do
"äöÜ".capitalize.should == "Äöü"
@ -86,7 +77,6 @@ describe "String#capitalize" do
it "does not allow invalid options" do
lambda { "abc".capitalize(:invalid_option) }.should raise_error(ArgumentError)
end
end
it "returns subclass instances when called on a subclass" do
StringSpecs::MyString.new("hello").capitalize.should be_an_instance_of(StringSpecs::MyString)
@ -101,7 +91,6 @@ describe "String#capitalize!" do
a.should == "Hello"
end
ruby_version_is '2.4' do
describe "full Unicode case mapping" do
it "modifies self in place for all of Unicode with no option" do
a = "äöÜ"
@ -177,7 +166,6 @@ describe "String#capitalize!" do
it "does not allow invalid options" do
lambda { a = "abc"; a.capitalize!(:invalid_option) }.should raise_error(ArgumentError)
end
end
it "returns nil when no changes are made" do
a = "Hello"

View file

@ -101,12 +101,10 @@ describe "String#casecmp independent of case" do
@lower_a_tilde.casecmp(@upper_a_tilde).should == 1
end
ruby_version_is "2.4" do
it "does not case fold" do
"ß".casecmp("ss").should == 1
end
end
end
describe "when comparing a subclass instance" do
it "returns -1 when less than other" do
@ -129,7 +127,6 @@ describe "String#casecmp independent of case" do
end
end
ruby_version_is "2.4" do
describe 'String#casecmp? independent of case' do
it 'returns true when equal to other' do
'abc'.casecmp?('abc').should == true
@ -195,11 +192,9 @@ ruby_version_is "2.4" do
end
end
ruby_version_is "2.4" do
it "case folds" do
"ß".casecmp?("ss").should be_true
end
end
ruby_version_is "2.4"..."2.5" do
it "raises a TypeError if other can't be converted to a string" do
@ -213,4 +208,3 @@ ruby_version_is "2.4" do
end
end
end
end

View file

@ -6,7 +6,6 @@ describe "String#concat" do
it_behaves_like :string_concat, :concat
it_behaves_like :string_concat_encoding, :concat
ruby_version_is "2.4" do
it "takes multiple arguments" do
str = "hello "
str.concat "wo", "", "rld"
@ -25,4 +24,3 @@ describe "String#concat" do
str.should == "hello"
end
end
end

View file

@ -8,21 +8,6 @@ describe "String#downcase" do
"hello".downcase.should == "hello"
end
ruby_version_is ''...'2.4' do
it "is locale insensitive (only replaces A-Z)" do
"ÄÖÜ".downcase.should == "ÄÖÜ"
str = Array.new(256) { |c| c.chr }.join
expected = Array.new(256) do |i|
c = i.chr
c.between?("A", "Z") ? c.downcase : c
end.join
str.downcase.should == expected
end
end
ruby_version_is '2.4' do
describe "full Unicode case mapping" do
it "works for all of Unicode with no option" do
"ÄÖÜ".downcase.should == "äöü"
@ -82,7 +67,6 @@ describe "String#downcase" do
it "does not allow invalid options" do
lambda { "ABC".downcase(:invalid_option) }.should raise_error(ArgumentError)
end
end
it "taints result when self is tainted" do
"".taint.downcase.tainted?.should == true
@ -102,7 +86,6 @@ describe "String#downcase!" do
a.should == "hello"
end
ruby_version_is '2.4' do
describe "full Unicode case mapping" do
it "modifies self in place for all of Unicode with no option" do
a = "ÄÖÜ"
@ -179,7 +162,6 @@ describe "String#downcase!" do
it "does not allow invalid options" do
lambda { a = "ABC"; a.downcase!(:invalid_option) }.should raise_error(ArgumentError)
end
end
it "returns nil if no modifications were made" do
a = "hello"

View file

@ -352,44 +352,6 @@ describe "String#dump" do
].should be_computed_by(:dump)
end
ruby_version_is ''...'2.4' do
it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with lower-case hex digits" do
[ [0200.chr('utf-8'), '"\u{80}"'],
[0201.chr('utf-8'), '"\u{81}"'],
[0202.chr('utf-8'), '"\u{82}"'],
[0203.chr('utf-8'), '"\u{83}"'],
[0204.chr('utf-8'), '"\u{84}"'],
[0206.chr('utf-8'), '"\u{86}"'],
[0207.chr('utf-8'), '"\u{87}"'],
[0210.chr('utf-8'), '"\u{88}"'],
[0211.chr('utf-8'), '"\u{89}"'],
[0212.chr('utf-8'), '"\u{8a}"'],
[0213.chr('utf-8'), '"\u{8b}"'],
[0214.chr('utf-8'), '"\u{8c}"'],
[0215.chr('utf-8'), '"\u{8d}"'],
[0216.chr('utf-8'), '"\u{8e}"'],
[0217.chr('utf-8'), '"\u{8f}"'],
[0220.chr('utf-8'), '"\u{90}"'],
[0221.chr('utf-8'), '"\u{91}"'],
[0222.chr('utf-8'), '"\u{92}"'],
[0223.chr('utf-8'), '"\u{93}"'],
[0224.chr('utf-8'), '"\u{94}"'],
[0225.chr('utf-8'), '"\u{95}"'],
[0226.chr('utf-8'), '"\u{96}"'],
[0227.chr('utf-8'), '"\u{97}"'],
[0230.chr('utf-8'), '"\u{98}"'],
[0231.chr('utf-8'), '"\u{99}"'],
[0232.chr('utf-8'), '"\u{9a}"'],
[0233.chr('utf-8'), '"\u{9b}"'],
[0234.chr('utf-8'), '"\u{9c}"'],
[0235.chr('utf-8'), '"\u{9d}"'],
[0236.chr('utf-8'), '"\u{9e}"'],
[0237.chr('utf-8'), '"\u{9f}"'],
].should be_computed_by(:dump)
end
end
ruby_version_is '2.4' do
it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with upper-case hex digits" do
[ [0200.chr('utf-8'), '"\u0080"'],
[0201.chr('utf-8'), '"\u0081"'],
@ -424,7 +386,6 @@ describe "String#dump" do
[0237.chr('utf-8'), '"\u009F"'],
].should be_computed_by(:dump)
end
end
it "includes .force_encoding(name) if the encoding isn't ASCII compatible" do
"\u{876}".encode('utf-16be').dump.end_with?(".force_encoding(\"UTF-16BE\")").should be_true

View file

@ -11,7 +11,6 @@ describe "String#lines" do
ary.should == ["hello ", "world"]
end
ruby_version_is '2.4' do
context "when `chomp` keyword argument is passed" do
it "removes new line characters" do
"hello \nworld\n".lines(chomp: true).should == ["hello ", "world"]
@ -19,4 +18,3 @@ describe "String#lines" do
end
end
end
end

View file

@ -149,7 +149,6 @@ describe "String#match" do
end
end
ruby_version_is "2.4" do
describe "String#match?" do
before :each do
# Resetting Regexp.last_match
@ -172,4 +171,3 @@ ruby_version_is "2.4" do
'string'.match?(/str/i, 1).should be_false
end
end
end

View file

@ -13,12 +13,10 @@ describe "String.new" do
str.encoding.should == Encoding::EUC_JP
end
ruby_version_is "2.4" do
it "accepts a capacity argument" do
String.new("", capacity: 100_000).should == ""
String.new("abc", capacity: 100_000).should == "abc"
end
end
it "returns a fully-formed String" do
str = String.new

View file

@ -42,7 +42,6 @@ describe "String#prepend" do
x.prepend("y".taint).tainted?.should be_true
end
ruby_version_is "2.4" do
it "takes multiple arguments" do
str = " world"
str.prepend "he", "", "llo"
@ -61,4 +60,3 @@ describe "String#prepend" do
str.should == "hello"
end
end
end

View file

@ -145,7 +145,6 @@ describe :string_each_line, shared: true do
lambda { "hello world".send(@method, :o).to_a }.should raise_error(TypeError)
end
ruby_version_is '2.4' do
context "when `chomp` keyword argument is passed" do
it "removes new line characters when separator is not specified" do
a = []
@ -175,4 +174,3 @@ describe :string_each_line, shared: true do
end
end
end
end

View file

@ -65,11 +65,9 @@ describe "String#split with String" do
end
it "defaults to $; when string isn't given or nil" do
begin
verbose = $VERBOSE
$VERBOSE = nil
suppress_warning do
old_fs = $;
begin
[",", ":", "", "XY", nil].each do |fs|
$; = fs
@ -86,7 +84,7 @@ describe "String#split with String" do
end
ensure
$; = old_fs
$VERBOSE = verbose
end
end
end
@ -241,11 +239,9 @@ describe "String#split with Regexp" do
end
it "defaults to $; when regexp isn't given or nil" do
begin
verbose = $VERBOSE
$VERBOSE = nil
suppress_warning do
old_fs = $;
begin
[/,/, /:/, //, /XY/, /./].each do |fs|
$; = fs
@ -262,7 +258,7 @@ describe "String#split with Regexp" do
end
ensure
$; = old_fs
$VERBOSE = verbose
end
end
end

View file

@ -14,15 +14,6 @@ describe "String#swapcase" do
"hello".taint.swapcase.tainted?.should == true
end
ruby_version_is ''...'2.4' do
it "is locale insensitive (only upcases a-z and only downcases A-Z)" do
"ÄÖÜ".swapcase.should == "ÄÖÜ"
"ärger".swapcase.should == "äRGER"
"BÄR".swapcase.should == "bÄr"
end
end
ruby_version_is '2.4' do
describe "full Unicode case mapping" do
it "works for all of Unicode with no option" do
"äÖü".swapcase.should == "ÄöÜ"
@ -79,7 +70,6 @@ describe "String#swapcase" do
it "does not allow invalid options" do
lambda { "abc".swapcase(:invalid_option) }.should raise_error(ArgumentError)
end
end
it "returns subclass instances when called on a subclass" do
StringSpecs::MyString.new("").swapcase.should be_an_instance_of(StringSpecs::MyString)
@ -94,7 +84,6 @@ describe "String#swapcase!" do
a.should == "CyBeR_pUnK11"
end
ruby_version_is '2.4' do
describe "full Unicode case mapping" do
it "modifies self in place for all of Unicode with no option" do
a = "äÖü"
@ -164,7 +153,6 @@ describe "String#swapcase!" do
it "does not allow invalid options" do
lambda { a = "abc"; a.swapcase!(:invalid_option) }.should raise_error(ArgumentError)
end
end
it "returns nil if no modifications were made" do
a = "+++---111222???"

View file

@ -12,6 +12,7 @@ describe "String#to_f" do
".5".to_f.should == 0.5
".5e1".to_f.should == 5.0
"5.".to_f.should == 5.0
"5e".to_f.should == 5.0
"5E".to_f.should == 5.0
end

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper'
ruby_version_is "2.4" do
describe "String#unpack1" do
it "returns the first value of #unpack" do
"ABCD".unpack1('x3C').should == "ABCD".unpack('x3C')[0]
@ -9,4 +8,3 @@ ruby_version_is "2.4" do
"A".unpack1("B*").should == "01000001"
end
end
end

View file

@ -8,21 +8,6 @@ describe "String#upcase" do
"hello".upcase.should == "HELLO"
end
ruby_version_is ''...'2.4' do
it "is locale insensitive (only replaces a-z)" do
"äöü".upcase.should == "äöü"
str = Array.new(256) { |c| c.chr }.join
expected = Array.new(256) do |i|
c = i.chr
c.between?("a", "z") ? c.upcase : c
end.join
str.upcase.should == expected
end
end
ruby_version_is '2.4' do
describe "full Unicode case mapping" do
it "works for all of Unicode with no option" do
"äöü".upcase.should == "ÄÖÜ"
@ -79,7 +64,6 @@ describe "String#upcase" do
it "does not allow invalid options" do
lambda { "abc".upcase(:invalid_option) }.should raise_error(ArgumentError)
end
end
it "taints result when self is tainted" do
"".taint.upcase.tainted?.should == true
@ -99,7 +83,6 @@ describe "String#upcase!" do
a.should == "HELLO"
end
ruby_version_is '2.4' do
describe "full Unicode case mapping" do
it "modifies self in place for all of Unicode with no option" do
a = "äöü"
@ -169,7 +152,6 @@ describe "String#upcase!" do
it "does not allow invalid options" do
lambda { a = "abc"; a.upcase!(:invalid_option) }.should raise_error(ArgumentError)
end
end
it "returns nil if no modifications were made" do
a = "HELLO"

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