mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Drop support for ruby 2.4 from ruby/spec
This commit is contained in:
parent
3a2073e61b
commit
826f44834f
Notes:
git
2020-04-01 15:36:48 +09:00
145 changed files with 2343 additions and 3347 deletions
10
.travis.yml
10
.travis.yml
|
|
@ -360,17 +360,17 @@ env:
|
|||
-Wunused-variable'
|
||||
- LDFLAGS=-Wno-unused-command-line-argument
|
||||
|
||||
- &rubyspec24
|
||||
name: Check ruby/spec version guards on Ruby 2.4
|
||||
- &rubyspec25
|
||||
name: Check ruby/spec version guards on Ruby 2.5
|
||||
language: ruby
|
||||
rvm: 2.4.9
|
||||
rvm: 2.5.7
|
||||
before_install:
|
||||
install:
|
||||
before_script: chmod -R u+w spec/ruby
|
||||
# -j randomly hangs.
|
||||
script: ruby -C spec/ruby ../mspec/bin/mspec .
|
||||
after_failure:
|
||||
- echo "ruby/spec failed on Ruby 2.4. This is likely because of a missing ruby_version_is guard, please add it. See spec/README.md."
|
||||
- echo "ruby/spec failed on Ruby 2.5. This is likely because of a missing ruby_version_is guard, please add it. See spec/README.md."
|
||||
|
||||
- &rubyspec27
|
||||
name: Check ruby/spec version guards on Ruby 2.7
|
||||
|
|
@ -435,7 +435,7 @@ matrix:
|
|||
- <<: *pedanticism
|
||||
- <<: *assertions
|
||||
- <<: *baseruby
|
||||
- <<: *rubyspec24
|
||||
- <<: *rubyspec25
|
||||
- <<: *rubyspec27
|
||||
- <<: *dependency
|
||||
# Build every commit (Allowed Failures):
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ specs in a manner compatible with multiple Ruby implementations.
|
|||
|
||||
## Requirements
|
||||
|
||||
MSpec requires Ruby 2.4 or more recent.
|
||||
MSpec requires Ruby 2.5 or more recent.
|
||||
|
||||
## Bundler
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ class MSpecScript
|
|||
end
|
||||
|
||||
def initialize
|
||||
ruby_version_is ""..."2.4" do
|
||||
abort "MSpec needs Ruby 2.4 or more recent"
|
||||
ruby_version_is ""..."2.5" do
|
||||
abort "MSpec needs Ruby 2.5 or more recent"
|
||||
end
|
||||
|
||||
config[:formatter] = nil
|
||||
|
|
|
|||
|
|
@ -1,20 +1,6 @@
|
|||
require 'mspec/guards/version'
|
||||
|
||||
if RUBY_ENGINE == "ruby"
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
# Kernel#warn does not delegate to Warning.warn in 2.4
|
||||
module Kernel
|
||||
remove_method :warn
|
||||
def warn(*messages)
|
||||
return if $VERBOSE == nil or messages.empty?
|
||||
msg = messages.join("\n")
|
||||
msg += "\n" unless msg.end_with?("\n")
|
||||
Warning.warn(msg)
|
||||
end
|
||||
private :warn
|
||||
end
|
||||
end
|
||||
|
||||
def Warning.warn(message)
|
||||
# Suppress any warning inside the method to prevent recursion
|
||||
verbose = $VERBOSE
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
inherit_from: .rubocop_todo.yml
|
||||
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.4
|
||||
TargetRubyVersion: 2.5
|
||||
DisplayCopNames: true
|
||||
Exclude:
|
||||
- command_line/fixtures/bad_syntax.rb
|
||||
|
|
|
|||
|
|
@ -133,12 +133,12 @@ Here is a list of the most commonly-used guards:
|
|||
#### Version guards
|
||||
|
||||
```ruby
|
||||
ruby_version_is ""..."2.4" do
|
||||
# Specs for RUBY_VERSION < 2.4
|
||||
ruby_version_is ""..."2.6 do
|
||||
# Specs for RUBY_VERSION < 2.6
|
||||
end
|
||||
|
||||
ruby_version_is "2.4" do
|
||||
# Specs for RUBY_VERSION >= 2.4
|
||||
ruby_version_is "2.6 do
|
||||
# Specs for RUBY_VERSION >= 2.6
|
||||
end
|
||||
```
|
||||
|
||||
|
|
@ -185,11 +185,11 @@ end
|
|||
#### Combining guards
|
||||
|
||||
```ruby
|
||||
guard -> { platform_is :windows and ruby_version_is ""..."2.5" } do
|
||||
# Windows and RUBY_VERSION < 2.5
|
||||
guard -> { platform_is :windows and ruby_version_is ""..."2.6" } do
|
||||
# Windows and RUBY_VERSION < 2.6
|
||||
end
|
||||
|
||||
guard_not -> { platform_is :windows and ruby_version_is ""..."2.5" } do
|
||||
guard_not -> { platform_is :windows and ruby_version_is ""..."2.6" } do
|
||||
# The opposite
|
||||
end
|
||||
```
|
||||
|
|
|
|||
|
|
@ -27,8 +27,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.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, 2.7.x, etc), and those are tested in TravisCI.
|
||||
ruby/spec describes the behavior of Ruby 2.5 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.5.x, 2.6.x, 2.7.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,8 @@ For older specs try these commits:
|
|||
* 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)
|
||||
* Ruby 2.4.10 - [Suite](https://github.com/ruby/spec/commit/f03892a0a9cac6972e0aa6f83cb08bb8e9b5739c) using [MSpec](https://github.com/ruby/mspec/commit/18fd75a7b4853d79d8148f6a503f99733be91712)
|
||||
* Ruby 2.5.8 - [Suite](https://github.com/ruby/spec/commit/f03892a0a9cac6972e0aa6f83cb08bb8e9b5739c) using [MSpec](https://github.com/ruby/mspec/commit/18fd75a7b4853d79d8148f6a503f99733be91712)
|
||||
|
||||
### Running the specs
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,11 @@ describe "The -l command line option" do
|
|||
"false\nfalse\nfalse\n"
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "chomps last line based on $/" do
|
||||
ruby_exe('BEGIN { $/ = "ones\n" }; puts $_', options: "-W0 -n -l", escape: true,
|
||||
args: " < #{@names}").should ==
|
||||
"alice j\nbob field\njames grey\n"
|
||||
end
|
||||
end
|
||||
|
||||
it "sets $\\ to the value of $/" do
|
||||
ruby_exe("puts $\\ == $/", options: "-W0 -n -l", escape: true,
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ describe "Array#<<" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Array#append" do
|
||||
it_behaves_like :array_push, :append
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -109,21 +109,11 @@ describe "Array#flatten" do
|
|||
-> { [@obj].flatten }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "calls respond_to_missing?(:to_ary, false) to try coercing" do
|
||||
def @obj.respond_to_missing?(*args) ScratchPad << args; false end
|
||||
[@obj].flatten.should == [@obj]
|
||||
ScratchPad.recorded.should == [[:to_ary, false]]
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "calls respond_to_missing?(:to_ary, true) to try coercing" do
|
||||
def @obj.respond_to_missing?(*args) ScratchPad << args; false end
|
||||
[@obj].flatten.should == [@obj]
|
||||
ScratchPad.recorded.should == [[:to_ary, true]]
|
||||
end
|
||||
end
|
||||
|
||||
it "does not call #to_ary if not defined when #respond_to_missing? returns false" do
|
||||
def @obj.respond_to_missing?(name, priv) ScratchPad << name; false end
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ require_relative '../../spec_helper'
|
|||
require_relative 'fixtures/classes'
|
||||
require_relative 'shared/unshift'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Array#prepend" do
|
||||
it_behaves_like :array_unshift, :prepend
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Binding#irb" do
|
||||
it "creates an IRB session with the binding in scope" do
|
||||
irb_fixture = fixture __FILE__, "irb.rb"
|
||||
|
|
@ -15,4 +14,3 @@ ruby_version_is "2.5" do
|
|||
out[-3..-1].should == ["a ** 2", "100", "exit"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ describe "Data" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "is deprecated" do
|
||||
-> { Data }.should complain(/constant ::Data is deprecated/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
require_relative '../../spec_helper'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Dir.children" do
|
||||
before :all do
|
||||
DirSpecs.create_mock_dirs
|
||||
|
|
@ -69,7 +68,6 @@ ruby_version_is "2.5" do
|
|||
-> { Dir.children DirSpecs.nonexistent }.should raise_error(SystemCallError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
describe "Dir#children" do
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
require_relative '../../spec_helper'
|
||||
require_relative 'fixtures/common'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Dir.each_child" do
|
||||
before :all do
|
||||
DirSpecs.create_mock_dirs
|
||||
|
|
@ -50,7 +49,6 @@ ruby_version_is "2.5" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
describe "Dir#each_child" do
|
||||
|
|
|
|||
|
|
@ -291,7 +291,6 @@ describe :dir_glob, shared: true do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
context ":base option passed" do
|
||||
before :each do
|
||||
@mock_dir = File.expand_path tmp('dir_glob_mock')
|
||||
|
|
@ -362,7 +361,6 @@ describe :dir_glob, shared: true do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe :dir_glob_recursive, shared: true do
|
||||
before :each do
|
||||
|
|
|
|||
|
|
@ -26,15 +26,6 @@ describe "Enumerable#all?" do
|
|||
-> { {}.all?(1, 2, 3) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "raises an ArgumentError when any arguments provided" do
|
||||
-> { @enum.all?(Proc.new {}) }.should raise_error(ArgumentError)
|
||||
-> { @enum.all?(nil) }.should raise_error(ArgumentError)
|
||||
-> { @empty.all?(1) }.should raise_error(ArgumentError)
|
||||
-> { @enum1.all?(1) {} }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "does not hide exceptions out of #each" do
|
||||
-> {
|
||||
EnumerableSpecs::ThrowingEach.new.all?
|
||||
|
|
@ -133,7 +124,6 @@ describe "Enumerable#all?" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe 'when given a pattern argument' do
|
||||
it "calls `===` on the pattern the return value " do
|
||||
pattern = EnumerableSpecs::Pattern.new { |x| x >= 0 }
|
||||
|
|
@ -198,4 +188,3 @@ describe "Enumerable#all?" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,15 +26,6 @@ describe "Enumerable#any?" do
|
|||
-> { {}.any?(1, 2, 3) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "raises an ArgumentError when any arguments provided" do
|
||||
-> { @enum.any?(Proc.new {}) }.should raise_error(ArgumentError)
|
||||
-> { @enum.any?(nil) }.should raise_error(ArgumentError)
|
||||
-> { @empty.any?(1) }.should raise_error(ArgumentError)
|
||||
-> { @enum1.any?(1) {} }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "does not hide exceptions out of #each" do
|
||||
-> {
|
||||
EnumerableSpecs::ThrowingEach.new.any?
|
||||
|
|
@ -147,7 +138,6 @@ describe "Enumerable#any?" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe 'when given a pattern argument' do
|
||||
it "calls `===` on the pattern the return value " do
|
||||
pattern = EnumerableSpecs::Pattern.new { |x| x == 2 }
|
||||
|
|
@ -211,4 +201,3 @@ describe "Enumerable#any?" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,15 +20,6 @@ describe "Enumerable#none?" do
|
|||
-> { {}.none?(1, 2, 3) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "raises an ArgumentError when any arguments provided" do
|
||||
-> { @enum.none?(Proc.new {}) }.should raise_error(ArgumentError)
|
||||
-> { @enum.none?(nil) }.should raise_error(ArgumentError)
|
||||
-> { @empty.none?(1) }.should raise_error(ArgumentError)
|
||||
-> { @enum.none?(1) {} }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "does not hide exceptions out of #each" do
|
||||
-> {
|
||||
EnumerableSpecs::ThrowingEach.new.none?
|
||||
|
|
@ -102,7 +93,6 @@ describe "Enumerable#none?" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe 'when given a pattern argument' do
|
||||
it "calls `===` on the pattern the return value " do
|
||||
pattern = EnumerableSpecs::Pattern.new { |x| x == 3 }
|
||||
|
|
@ -164,4 +154,3 @@ describe "Enumerable#none?" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,15 +20,6 @@ describe "Enumerable#one?" do
|
|||
-> { {}.one?(1, 2, 3) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "raises an ArgumentError when any arguments provided" do
|
||||
-> { @enum.one?(Proc.new {}) }.should raise_error(ArgumentError)
|
||||
-> { @enum.one?(nil) }.should raise_error(ArgumentError)
|
||||
-> { @empty.one?(1) }.should raise_error(ArgumentError)
|
||||
-> { @enum.one?(1) {} }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "does not hide exceptions out of #each" do
|
||||
-> {
|
||||
EnumerableSpecs::ThrowingEach.new.one?
|
||||
|
|
@ -93,7 +84,6 @@ describe "Enumerable#one?" do
|
|||
end
|
||||
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe 'when given a pattern argument' do
|
||||
it "calls `===` on the pattern the return value " do
|
||||
pattern = EnumerableSpecs::Pattern.new { |x| x == 1 }
|
||||
|
|
@ -166,4 +156,3 @@ describe "Enumerable#one?" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Exception#full_message" do
|
||||
it "returns formatted string of exception using the same format that is used to print an uncaught exceptions to stderr" do
|
||||
e = RuntimeError.new("Some runtime error")
|
||||
|
|
@ -91,4 +90,3 @@ ruby_version_is "2.5" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ describe "Exception" do
|
|||
FloatDomainError => nil,
|
||||
},
|
||||
RegexpError => nil,
|
||||
RuntimeError => nil,
|
||||
RuntimeError => {
|
||||
FrozenError => nil,
|
||||
},
|
||||
SystemCallError => nil,
|
||||
ThreadError => nil,
|
||||
TypeError => nil,
|
||||
|
|
@ -47,9 +49,7 @@ describe "Exception" do
|
|||
SystemStackError => nil,
|
||||
},
|
||||
}
|
||||
ruby_version_is "2.5" do
|
||||
hierarchy[Exception][StandardError][RuntimeError] = {FrozenError => nil}
|
||||
end
|
||||
|
||||
traverse = -> parent_class, parent_subclass_hash {
|
||||
parent_subclass_hash.each do |child_class, child_subclass_hash|
|
||||
child_class.class.should == Class
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe "File.atime" do
|
|||
File.atime(@file).should be_kind_of(Time)
|
||||
end
|
||||
|
||||
guard -> { platform_is :linux or (platform_is :windows and ruby_version_is '2.5') } do
|
||||
guard -> { platform_is :linux or platform_is :windows } do
|
||||
## NOTE also that some Linux systems disable atime (e.g. via mount params) for better filesystem speed.
|
||||
it "returns the last access time for the named file with microseconds" do
|
||||
supports_subseconds = Integer(`stat -c%x '#{__FILE__}'`[/\.(\d+)/, 1], 10)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ describe "File.ctime" do
|
|||
File.ctime(@file).should be_kind_of(Time)
|
||||
end
|
||||
|
||||
guard -> { platform_is :linux or (platform_is :windows and ruby_version_is '2.5') } do
|
||||
guard -> { platform_is :linux or platform_is :windows } do
|
||||
it "returns the change time for the named file (the time at which directory information about the file was changed, not the file itself) with microseconds." do
|
||||
supports_subseconds = Integer(`stat -c%z '#{__FILE__}'`[/\.(\d+)/, 1], 10)
|
||||
if supports_subseconds != 0
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "File.lutime" do
|
||||
platform_is_not :windows do
|
||||
before :each do
|
||||
|
|
@ -37,4 +36,3 @@ ruby_version_is "2.5" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe "File.mtime" do
|
|||
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
|
||||
guard -> { platform_is :linux or platform_is :windows } do
|
||||
it "returns the modification Time of the file with microseconds" do
|
||||
supports_subseconds = Integer(`stat -c%y '#{__FILE__}'`[/\.(\d+)/, 1], 10)
|
||||
if supports_subseconds != 0
|
||||
|
|
|
|||
|
|
@ -623,13 +623,11 @@ describe "File.open" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "raises ArgumentError if mixing :newline and binary mode" do
|
||||
-> {
|
||||
File.open(@file, "rb", newline: :universal) {}
|
||||
}.should raise_error(ArgumentError, "newline decorator with binary mode")
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
context "'x' flag" do
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ describe :file_path, shared: true do
|
|||
@file.send(@method).encoding.should == Encoding.find("euc-jp")
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
platform_is :linux do
|
||||
guard -> { defined?(File::TMPFILE) } do
|
||||
before :each do
|
||||
|
|
@ -74,4 +73,3 @@ describe :file_path, shared: true do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ describe "Float#<=>" do
|
|||
coercible.call_count.should == 3
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "raises TypeError when #coerce misbehaves" do
|
||||
klass = Class.new do
|
||||
def coerce(other)
|
||||
|
|
@ -46,7 +45,6 @@ describe "Float#<=>" do
|
|||
4.2 <=> bad_coercible
|
||||
}.should raise_error(TypeError, "coerce must return [x, y]")
|
||||
end
|
||||
end
|
||||
|
||||
# The 4 tests below are taken from matz's revision 23730 for Ruby trunk
|
||||
#
|
||||
|
|
|
|||
|
|
@ -1,27 +1,6 @@
|
|||
require_relative '../fixtures/classes'
|
||||
|
||||
describe :float_arithmetic_exception_in_coerce, shared: true do
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "rescues exception (StandardError and subclasses) raised in other#coerce and raises TypeError" do
|
||||
b = mock("numeric with failed #coerce")
|
||||
b.should_receive(:coerce).and_raise(FloatSpecs::CoerceError)
|
||||
|
||||
# e.g. 1.0 > b
|
||||
-> { 1.0.send(@method, b) }.should raise_error(TypeError, /MockObject can't be coerced into Float/)
|
||||
end
|
||||
|
||||
it "does not rescue Exception and StandardError siblings raised in other#coerce" do
|
||||
[Exception, NoMemoryError].each do |exception|
|
||||
b = mock("numeric with failed #coerce")
|
||||
b.should_receive(:coerce).and_raise(exception)
|
||||
|
||||
# e.g. 1.0 > b
|
||||
-> { 1.0.send(@method, b) }.should raise_error(exception)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "does not rescue exception raised in other#coerce" do
|
||||
b = mock("numeric with failed #coerce")
|
||||
b.should_receive(:coerce).and_raise(FloatSpecs::CoerceError)
|
||||
|
|
@ -30,4 +9,3 @@ describe :float_arithmetic_exception_in_coerce, shared: true do
|
|||
-> { 1.0.send(@method, b) }.should raise_error(FloatSpecs::CoerceError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,29 +1,6 @@
|
|||
require_relative '../fixtures/classes'
|
||||
|
||||
describe :float_comparison_exception_in_coerce, shared: true do
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "rescues exception (StandardError and subclasses) raised in other#coerce and raises ArgumentError" do
|
||||
b = mock("numeric with failed #coerce")
|
||||
b.should_receive(:coerce).and_raise(FloatSpecs::CoerceError)
|
||||
|
||||
# e.g. 1.0 > b
|
||||
-> {
|
||||
-> { 1.0.send(@method, b) }.should raise_error(ArgumentError, /comparison of Float with MockObject failed/)
|
||||
}.should complain(/Numerical comparison operators will no more rescue exceptions of #coerce/)
|
||||
end
|
||||
|
||||
it "does not rescue Exception and StandardError siblings raised in other#coerce" do
|
||||
[Exception, NoMemoryError].each do |exception|
|
||||
b = mock("numeric with failed #coerce")
|
||||
b.should_receive(:coerce).and_raise(exception)
|
||||
|
||||
# e.g. 1.0 > b
|
||||
-> { 1.0.send(@method, b) }.should raise_error(exception)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "does not rescue exception raised in other#coerce" do
|
||||
b = mock("numeric with failed #coerce")
|
||||
b.should_receive(:coerce).and_raise(FloatSpecs::CoerceError)
|
||||
|
|
@ -32,4 +9,3 @@ describe :float_comparison_exception_in_coerce, shared: true do
|
|||
-> { 1.0.send(@method, b) }.should raise_error(FloatSpecs::CoerceError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Hash#slice" do
|
||||
before :each do
|
||||
@hash = { a: 1, b: 2, c: 3 }
|
||||
|
|
@ -52,4 +51,3 @@ ruby_version_is "2.5" do
|
|||
ScratchPad.recorded.should == []
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Hash#transform_keys" do
|
||||
before :each do
|
||||
@hash = { a: 1, b: 2, c: 3 }
|
||||
|
|
@ -129,4 +128,3 @@ ruby_version_is "2.5" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
describe "Integer#allbits?" do
|
||||
it "returns true iff all the bits of the argument are set in the receiver" do
|
||||
42.allbits?(42).should == true
|
||||
|
|
@ -36,4 +35,3 @@ ruby_version_is '2.5' do
|
|||
-> { 13.allbits?(:symbol) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
describe "Integer#anybits?" do
|
||||
it "returns true iff all the bits of the argument are set in the receiver" do
|
||||
42.anybits?(42).should == true
|
||||
|
|
@ -35,4 +34,3 @@ ruby_version_is '2.5' do
|
|||
-> { 13.anybits?(:symbol) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -124,24 +124,12 @@ describe "Integer#<=>" do
|
|||
@big <=> @num
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "returns nil if #coerce raises an exception" do
|
||||
@num.should_receive(:coerce).with(@big).and_raise(RuntimeError)
|
||||
-> {
|
||||
@result = (@big <=> @num)
|
||||
}.should complain(/Numerical comparison operators will no more rescue exceptions/)
|
||||
@result.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "lets the exception go through if #coerce raises an exception" do
|
||||
@num.should_receive(:coerce).with(@big).and_raise(RuntimeError.new("my error"))
|
||||
-> {
|
||||
@big <=> @num
|
||||
}.should raise_error(RuntimeError, "my error")
|
||||
end
|
||||
end
|
||||
|
||||
it "raises an exception if #coerce raises a non-StandardError exception" do
|
||||
@num.should_receive(:coerce).with(@big).and_raise(Exception)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@ require_relative '../../spec_helper'
|
|||
require_relative 'shared/arithmetic_coerce'
|
||||
|
||||
describe "Integer#/" do
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it_behaves_like :integer_arithmetic_coerce_rescue, :/
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it_behaves_like :integer_arithmetic_coerce_not_rescue, :/
|
||||
end
|
||||
|
||||
context "fixnum" do
|
||||
it "returns self divided by the given argument" do
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@ require_relative '../../spec_helper'
|
|||
require_relative 'shared/comparison_coerce'
|
||||
|
||||
describe "Integer#>" do
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it_behaves_like :integer_comparison_coerce_rescue, :>
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it_behaves_like :integer_comparison_coerce_not_rescue, :>
|
||||
end
|
||||
|
||||
context "fixnum" do
|
||||
it "returns true if self is greater than the given argument" do
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@ require_relative '../../spec_helper'
|
|||
require_relative 'shared/comparison_coerce'
|
||||
|
||||
describe "Integer#>=" do
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it_behaves_like :integer_comparison_coerce_rescue, :>=
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it_behaves_like :integer_comparison_coerce_not_rescue, :>=
|
||||
end
|
||||
|
||||
context "fixnum" do
|
||||
it "returns true if self is greater than or equal to the given argument" do
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@ require_relative '../../spec_helper'
|
|||
require_relative 'shared/comparison_coerce'
|
||||
|
||||
describe "Integer#<" do
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it_behaves_like :integer_comparison_coerce_rescue, :<
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it_behaves_like :integer_comparison_coerce_not_rescue, :<
|
||||
end
|
||||
|
||||
context "fixnum" do
|
||||
it "returns true if self is less than the given argument" do
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@ require_relative '../../spec_helper'
|
|||
require_relative 'shared/comparison_coerce'
|
||||
|
||||
describe "Integer#<=" do
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it_behaves_like :integer_comparison_coerce_rescue, :<=
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it_behaves_like :integer_comparison_coerce_not_rescue, :<=
|
||||
end
|
||||
|
||||
context "fixnum" do
|
||||
it "returns true if self is less than or equal to other" do
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@ require_relative '../../spec_helper'
|
|||
require_relative 'shared/arithmetic_coerce'
|
||||
|
||||
describe "Integer#-" do
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it_behaves_like :integer_arithmetic_coerce_rescue, :-
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it_behaves_like :integer_arithmetic_coerce_not_rescue, :-
|
||||
end
|
||||
|
||||
context "fixnum" do
|
||||
it "returns self minus the given Integer" do
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@ require_relative '../../spec_helper'
|
|||
require_relative 'shared/arithmetic_coerce'
|
||||
|
||||
describe "Integer#*" do
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it_behaves_like :integer_arithmetic_coerce_rescue, :*
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it_behaves_like :integer_arithmetic_coerce_not_rescue, :*
|
||||
end
|
||||
|
||||
context "fixnum" do
|
||||
it "returns self multiplied by the given Integer" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
describe "Integer#nobits?" do
|
||||
it "returns true iff all no bits of the argument are set in the receiver" do
|
||||
42.nobits?(42).should == false
|
||||
|
|
@ -35,4 +34,3 @@ ruby_version_is '2.5' do
|
|||
-> { 13.nobits?(:symbol) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@ require_relative '../../spec_helper'
|
|||
require_relative 'shared/arithmetic_coerce'
|
||||
|
||||
describe "Integer#+" do
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it_behaves_like :integer_arithmetic_coerce_rescue, :+
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it_behaves_like :integer_arithmetic_coerce_not_rescue, :+
|
||||
end
|
||||
|
||||
context "fixnum" do
|
||||
it "returns self plus the given Integer" do
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ require_relative '../../spec_helper'
|
|||
require_relative 'fixtures/classes'
|
||||
require_relative 'shared/exponent'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Integer#pow" do
|
||||
context "one argument is passed" do
|
||||
it_behaves_like :integer_exponent, :pow
|
||||
|
|
@ -46,4 +45,3 @@ ruby_version_is "2.5" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,14 +6,6 @@ describe "Integer#round" do
|
|||
it_behaves_like :integer_to_i, :round
|
||||
it_behaves_like :integer_rounding_positive_precision, :round
|
||||
|
||||
ruby_version_is ""..."2.5" do # Not just since 2.4
|
||||
it "rounds itself as a float if passed a positive precision" do
|
||||
[2, -4, 10**70, -10**100].each do |v|
|
||||
v.round(42).should eql(v.to_f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# redmine:5228
|
||||
it "returns itself rounded if passed a negative value" do
|
||||
+249.round(-2).should eql(+200)
|
||||
|
|
@ -78,21 +70,11 @@ describe "Integer#round" do
|
|||
(-25).round(-1, half: nil).should eql(-30)
|
||||
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
|
||||
35.round(1, half: :up).should eql(35.0)
|
||||
35.round(1, half: :down).should eql(35.0)
|
||||
35.round(1, half: :even).should eql(35.0)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "returns itself if passed a positive precision and the half option" do
|
||||
35.round(1, half: :up).should eql(35)
|
||||
35.round(1, half: :down).should eql(35)
|
||||
35.round(1, half: :even).should eql(35)
|
||||
end
|
||||
end
|
||||
|
||||
it "raises ArgumentError for an unknown rounding mode" do
|
||||
-> { 42.round(-1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/)
|
||||
|
|
|
|||
|
|
@ -1,25 +1,5 @@
|
|||
require_relative '../fixtures/classes'
|
||||
|
||||
describe :integer_arithmetic_coerce_rescue, shared: true do
|
||||
it "rescues exception (StandardError and subclasses) raised in other#coerce and raises TypeError" do
|
||||
b = mock("numeric with failed #coerce")
|
||||
b.should_receive(:coerce).and_raise(IntegerSpecs::CoerceError)
|
||||
|
||||
# e.g. 1 + b
|
||||
-> { 1.send(@method, b) }.should raise_error(TypeError, /MockObject can't be coerced into Integer/)
|
||||
end
|
||||
|
||||
it "does not rescue Exception and StandardError siblings raised in other#coerce" do
|
||||
[Exception, NoMemoryError].each do |exception|
|
||||
b = mock("numeric with failed #coerce")
|
||||
b.should_receive(:coerce).and_raise(exception)
|
||||
|
||||
# e.g. 1 + b
|
||||
-> { 1.send(@method, b) }.should raise_error(exception)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe :integer_arithmetic_coerce_not_rescue, shared: true do
|
||||
it "does not rescue exception raised in other#coerce" do
|
||||
b = mock("numeric with failed #coerce")
|
||||
|
|
|
|||
|
|
@ -11,19 +11,9 @@ describe :integer_rounding_positive_precision, shared: true do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it "returns itself as a float if passed a positive precision" do
|
||||
[2, -4, 10**70, -10**100].each do |v|
|
||||
v.send(@method, 42).should eql(v.to_f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "returns itself if passed a positive precision" do
|
||||
[2, -4, 10**70, -10**100].each do |v|
|
||||
v.send(@method, 42).should eql(v)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Integer.sqrt" do
|
||||
it "returns an integer" do
|
||||
Integer.sqrt(10).should be_kind_of(Integer)
|
||||
|
|
@ -30,4 +29,3 @@ ruby_version_is "2.5" do
|
|||
-> { Integer.sqrt("test") }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ describe "IO#close" do
|
|||
@io.close.should be_nil
|
||||
end
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
it 'raises an IOError with a clear message' do
|
||||
read_io, write_io = IO.pipe
|
||||
going_to_read = false
|
||||
|
|
@ -61,7 +60,6 @@ describe "IO#close" do
|
|||
write_io.close
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "IO#close on an IO.popen stream" do
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
platform_is_not :windows do
|
||||
describe "IO#pread" do
|
||||
before :each do
|
||||
|
|
@ -49,4 +48,3 @@ ruby_version_is "2.5" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
platform_is_not :windows do
|
||||
describe "IO#pwrite" do
|
||||
before :each do
|
||||
|
|
@ -42,4 +41,3 @@ ruby_version_is "2.5" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -126,7 +126,6 @@ end
|
|||
describe "IO#write" do
|
||||
it_behaves_like :io_write, :write
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "accepts multiple arguments" do
|
||||
IO.pipe do |r, w|
|
||||
w.write("foo", "bar")
|
||||
|
|
@ -136,7 +135,6 @@ describe "IO#write" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
platform_is :windows do
|
||||
describe "IO#write on Windows" do
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ describe "Kernel#freeze" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "on a Complex" do
|
||||
it "has no effect since it is already frozen" do
|
||||
c = Complex(1.3, 3.1)
|
||||
|
|
@ -67,7 +66,6 @@ describe "Kernel#freeze" do
|
|||
r.freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "causes mutative calls to raise RuntimeError" do
|
||||
o = Class.new do
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ describe "Kernel#frozen?" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "on a Complex" do
|
||||
it "returns true" do
|
||||
c = Complex(1.3, 3.1)
|
||||
|
|
@ -75,4 +74,3 @@ describe "Kernel#frozen?" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Kernel#pp" do
|
||||
it "lazily loads the 'pp' library and delegates the call to that library" do
|
||||
# Run in child process to ensure 'pp' hasn't been loaded yet.
|
||||
|
|
@ -8,4 +7,3 @@ ruby_version_is "2.5" do
|
|||
output.should == "[1, 2, 3]\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -103,19 +103,6 @@ describe :kernel_dup_clone, shared: true do
|
|||
:my_symbol.send(@method).should == :my_symbol
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.5' do
|
||||
it "raises a TypeError for Complex" do
|
||||
c = Complex(1.3, 3.1)
|
||||
-> { c.send(@method) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError for Rational" do
|
||||
r = Rational(1, 3)
|
||||
-> { r.send(@method) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
it "returns self for Complex" do
|
||||
c = Complex(1.3, 3.1)
|
||||
c.send(@method).should equal c
|
||||
|
|
@ -126,4 +113,3 @@ describe :kernel_dup_clone, shared: true do
|
|||
r.send(@method).should equal r
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -354,18 +354,6 @@ describe :kernel_require, shared: true do
|
|||
rm_r @dir, @symlink_to_dir
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.4.4" do
|
||||
it "canonicalizes neither the entry in $LOAD_PATH nor the filename passed to #require" do
|
||||
$LOAD_PATH.unshift(@symlink_to_dir)
|
||||
@object.require("symfile").should be_true
|
||||
loaded_feature = "#{@symlink_to_dir}/symfile.rb"
|
||||
ScratchPad.recorded.should == [loaded_feature]
|
||||
$".last.should == loaded_feature
|
||||
$LOAD_PATH[0].should == @symlink_to_dir
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.4.4" do
|
||||
it "canonicalizes the entry in $LOAD_PATH but not the filename passed to #require" do
|
||||
$LOAD_PATH.unshift(@symlink_to_dir)
|
||||
@object.require("symfile").should be_true
|
||||
|
|
@ -376,7 +364,6 @@ describe :kernel_require, shared: true do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "does not store the path if the load fails" do
|
||||
$LOAD_PATH << CODE_LOADING_DIR
|
||||
|
|
@ -527,21 +514,6 @@ describe :kernel_require, shared: true do
|
|||
ScratchPad.recorded.should == []
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "complex, enumerator, rational, thread and unicode_normalize are already required" do
|
||||
provided = %w[complex enumerator rational thread unicode_normalize]
|
||||
features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
|
||||
provided.each { |feature|
|
||||
features.should =~ /\b#{feature}\.(rb|so|jar)$/
|
||||
}
|
||||
|
||||
code = provided.map { |f| "puts require #{f.inspect}\n" }.join
|
||||
required = ruby_exe(code, options: '--disable-gems')
|
||||
required.should == "false\n" * provided.size
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "complex, enumerator, rational and thread are already required" do
|
||||
provided = %w[complex enumerator rational thread]
|
||||
features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
|
||||
|
|
@ -563,7 +535,6 @@ describe :kernel_require, shared: true do
|
|||
-> { @object.require("unicode_normalize") }.should raise_error(LoadError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "(shell expansion)" do
|
||||
before :each do
|
||||
|
|
|
|||
|
|
@ -345,19 +345,11 @@ describe :kernel_sprintf, shared: true do
|
|||
end
|
||||
|
||||
describe "%" do
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "alone displays the percent sign" do
|
||||
@method.call("%").should == "%"
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "alone raises an ArgumentError" do
|
||||
-> {
|
||||
@method.call("%")
|
||||
}.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "is escaped by %" do
|
||||
@method.call("%%").should == "%"
|
||||
|
|
@ -876,7 +868,6 @@ describe :kernel_sprintf, shared: true do
|
|||
}.should raise_error(KeyError)
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "sets the Hash as the receiver of KeyError" do
|
||||
-> {
|
||||
@method.call("%<foo>s", @object)
|
||||
|
|
@ -894,4 +885,3 @@ describe :kernel_sprintf, shared: true do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ describe "Kernel#warn" do
|
|||
}.should output(nil, "to_s called\n")
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe ":uplevel keyword argument" do
|
||||
before :each do
|
||||
$VERBOSE = true
|
||||
|
|
@ -154,4 +153,3 @@ describe "Kernel#warn" do
|
|||
-> { warn('foo', **h) }.should complain("foo\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
require_relative '../../spec_helper'
|
||||
require_relative 'shared/then'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Kernel#yield_self" do
|
||||
it_behaves_like :kernel_then, :yield_self
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ require_relative '../../spec_helper'
|
|||
require_relative 'fixtures/classes'
|
||||
require_relative 'shared/call'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Method#===" do
|
||||
it_behaves_like :method_call, :===
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -81,16 +81,9 @@ describe "Module#alias_method" do
|
|||
-> { @class.make_alias mock('x'), :public_one }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.5' do
|
||||
it "is a private method" do
|
||||
-> { @class.alias_method :ichi, :public_one }.should raise_error(NoMethodError)
|
||||
end
|
||||
end
|
||||
ruby_version_is '2.5' do
|
||||
it "is a public method" do
|
||||
Module.should have_public_instance_method(:alias_method, false)
|
||||
end
|
||||
end
|
||||
|
||||
it "returns self" do
|
||||
@class.send(:alias_method, :checking_return_value, :public_one).should equal(@class)
|
||||
|
|
|
|||
|
|
@ -63,16 +63,9 @@ describe "Module#attr_accessor" do
|
|||
-> { c.new.foo=1 }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.5' do
|
||||
it "is a private method" do
|
||||
Module.should have_private_instance_method(:attr_accessor, false)
|
||||
end
|
||||
end
|
||||
ruby_version_is '2.5' do
|
||||
it "is a public method" do
|
||||
Module.should have_public_instance_method(:attr_accessor, false)
|
||||
end
|
||||
end
|
||||
|
||||
describe "on immediates" do
|
||||
before :each do
|
||||
|
|
|
|||
|
|
@ -58,14 +58,7 @@ describe "Module#attr_reader" do
|
|||
-> { c.new.foo }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.5' do
|
||||
it "is a private method" do
|
||||
Module.should have_private_instance_method(:attr_reader, false)
|
||||
end
|
||||
end
|
||||
ruby_version_is '2.5' do
|
||||
it "is a public method" do
|
||||
Module.should have_public_instance_method(:attr_reader, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -142,14 +142,7 @@ describe "Module#attr" do
|
|||
}.should complain(/boolean argument is obsoleted/, verbose: true)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.5' do
|
||||
it "is a private method" do
|
||||
Module.should have_private_instance_method(:attr, false)
|
||||
end
|
||||
end
|
||||
ruby_version_is '2.5' do
|
||||
it "is a public method" do
|
||||
Module.should have_public_instance_method(:attr, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -58,14 +58,7 @@ describe "Module#attr_writer" do
|
|||
-> { c.new.foo=1 }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.5' do
|
||||
it "is a private method" do
|
||||
Module.should have_private_instance_method(:attr_writer, false)
|
||||
end
|
||||
end
|
||||
ruby_version_is '2.5' do
|
||||
it "is a public method" do
|
||||
Module.should have_public_instance_method(:attr_writer, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -355,16 +355,9 @@ describe "Module#define_method" do
|
|||
klass.new.string_test.should == "string_test result"
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.5' do
|
||||
it "is a private method" do
|
||||
Module.should have_private_instance_method(:define_method)
|
||||
end
|
||||
end
|
||||
ruby_version_is '2.5' do
|
||||
it "is a public method" do
|
||||
Module.should have_public_instance_method(:define_method)
|
||||
end
|
||||
end
|
||||
|
||||
it "returns its symbol" do
|
||||
class DefineMethodSpecClass
|
||||
|
|
|
|||
|
|
@ -393,27 +393,6 @@ describe "Module#refine" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "" ... "2.5" do
|
||||
it "is not honored by string interpolation" do
|
||||
refinement = Module.new do
|
||||
refine Integer do
|
||||
def to_s
|
||||
"foo"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
result = nil
|
||||
Module.new do
|
||||
using refinement
|
||||
result = "#{1}"
|
||||
end
|
||||
|
||||
result.should == "1"
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "is honored by string interpolation" do
|
||||
refinement = Module.new do
|
||||
refine Integer do
|
||||
|
|
@ -431,7 +410,6 @@ describe "Module#refine" do
|
|||
|
||||
result.should == "foo"
|
||||
end
|
||||
end
|
||||
|
||||
it "is honored by Kernel#binding" do
|
||||
refinement = Module.new do
|
||||
|
|
|
|||
|
|
@ -20,16 +20,9 @@ describe "Module#remove_method" do
|
|||
@module = Module.new { def method_to_remove; end }
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.5' do
|
||||
it "is a private method" do
|
||||
Module.should have_private_instance_method(:remove_method, false)
|
||||
end
|
||||
end
|
||||
ruby_version_is '2.5' do
|
||||
it "is a public method" do
|
||||
Module.should have_public_instance_method(:remove_method, false)
|
||||
end
|
||||
end
|
||||
|
||||
it "removes the method from a class" do
|
||||
klass = Class.new do
|
||||
|
|
|
|||
|
|
@ -18,16 +18,9 @@ describe "Module#undef_method" do
|
|||
@module = Module.new { def method_to_undef; end }
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.5' do
|
||||
it "is a private method" do
|
||||
Module.should have_private_instance_method(:undef_method, false)
|
||||
end
|
||||
end
|
||||
ruby_version_is '2.5' do
|
||||
it "is a public method" do
|
||||
Module.should have_public_instance_method(:undef_method, false)
|
||||
end
|
||||
end
|
||||
|
||||
it "requires multiple arguments" do
|
||||
Module.instance_method(:undef_method).arity.should < 0
|
||||
|
|
|
|||
|
|
@ -224,33 +224,25 @@ describe :numeric_step, :shared => true do
|
|||
end
|
||||
|
||||
describe "when step is a String" do
|
||||
error = nil
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
error = TypeError
|
||||
end
|
||||
ruby_version_is "2.5" do
|
||||
error = ArgumentError
|
||||
end
|
||||
|
||||
describe "with self and stop as Fixnums" do
|
||||
it "raises an #{error} when step is a numeric representation" do
|
||||
-> { @step.call(1, 5, "1") {} }.should raise_error(error)
|
||||
-> { @step.call(1, 5, "0.1") {} }.should raise_error(error)
|
||||
-> { @step.call(1, 5, "1/3") {} }.should raise_error(error)
|
||||
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)
|
||||
-> { @step.call(1, 5, "1/3") {} }.should raise_error(ArgumentError)
|
||||
end
|
||||
it "raises an #{error} with step as an alphanumeric string" do
|
||||
-> { @step.call(1, 5, "foo") {} }.should raise_error(error)
|
||||
it "raises an ArgumentError with step as an alphanumeric string" do
|
||||
-> { @step.call(1, 5, "foo") {} }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with self and stop as Floats" do
|
||||
it "raises an #{error} when step is a numeric representation" do
|
||||
-> { @step.call(1.1, 5.1, "1") {} }.should raise_error(error)
|
||||
-> { @step.call(1.1, 5.1, "0.1") {} }.should raise_error(error)
|
||||
-> { @step.call(1.1, 5.1, "1/3") {} }.should raise_error(error)
|
||||
it "raises an ArgumentError when step is a numeric representation" do
|
||||
-> { @step.call(1.1, 5.1, "1") {} }.should raise_error(ArgumentError)
|
||||
-> { @step.call(1.1, 5.1, "0.1") {} }.should raise_error(ArgumentError)
|
||||
-> { @step.call(1.1, 5.1, "1/3") {} }.should raise_error(ArgumentError)
|
||||
end
|
||||
it "raises an #{error} with step as an alphanumeric string" do
|
||||
-> { @step.call(1.1, 5.1, "foo") {} }.should raise_error(error)
|
||||
it "raises an ArgumentError with step as an alphanumeric string" do
|
||||
-> { @step.call(1.1, 5.1, "foo") {} }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -302,33 +294,25 @@ describe :numeric_step, :shared => true do
|
|||
describe "returned Enumerator" do
|
||||
describe "size" do
|
||||
describe "when step is a String" do
|
||||
error = nil
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
error = TypeError
|
||||
end
|
||||
ruby_version_is "2.5" do
|
||||
error = ArgumentError
|
||||
end
|
||||
|
||||
describe "with self and stop as Fixnums" do
|
||||
it "raises an #{error} when step is a numeric representation" do
|
||||
-> { @step.call(1, 5, "1").size }.should raise_error(error)
|
||||
-> { @step.call(1, 5, "0.1").size }.should raise_error(error)
|
||||
-> { @step.call(1, 5, "1/3").size }.should raise_error(error)
|
||||
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)
|
||||
-> { @step.call(1, 5, "1/3").size }.should raise_error(ArgumentError)
|
||||
end
|
||||
it "raises an #{error} with step as an alphanumeric string" do
|
||||
-> { @step.call(1, 5, "foo").size }.should raise_error(error)
|
||||
it "raises an ArgumentError with step as an alphanumeric string" do
|
||||
-> { @step.call(1, 5, "foo").size }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with self and stop as Floats" do
|
||||
it "raises an #{error} when step is a numeric representation" do
|
||||
-> { @step.call(1.1, 5.1, "1").size }.should raise_error(error)
|
||||
-> { @step.call(1.1, 5.1, "0.1").size }.should raise_error(error)
|
||||
-> { @step.call(1.1, 5.1, "1/3").size }.should raise_error(error)
|
||||
it "raises an ArgumentError when step is a numeric representation" do
|
||||
-> { @step.call(1.1, 5.1, "1").size }.should raise_error(ArgumentError)
|
||||
-> { @step.call(1.1, 5.1, "0.1").size }.should raise_error(ArgumentError)
|
||||
-> { @step.call(1.1, 5.1, "1/3").size }.should raise_error(ArgumentError)
|
||||
end
|
||||
it "raises an #{error} with step as an alphanumeric string" do
|
||||
-> { @step.call(1.1, 5.1, "foo").size }.should raise_error(error)
|
||||
it "raises an ArgumentError with step as an alphanumeric string" do
|
||||
-> { @step.call(1.1, 5.1, "foo").size }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
describe 'Process#last_status' do
|
||||
it 'returns the status of the last executed child process in the current thread' do
|
||||
pid = Process.wait Process.spawn("exit 0")
|
||||
|
|
@ -17,4 +16,3 @@ ruby_version_is '2.5' do
|
|||
-> { Process.last_status(1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ describe "Process.times" do
|
|||
Process.times.utime.should > user
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
platform_is_not :windows do
|
||||
it "uses getrusage when available to improve precision beyond milliseconds" do
|
||||
max = 10_000
|
||||
|
|
@ -34,4 +33,3 @@ describe "Process.times" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
# -*- encoding: binary -*-
|
||||
require_relative '../../spec_helper'
|
||||
require_relative 'shared/urandom'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Random.urandom" do
|
||||
it_behaves_like :random_urandom, :urandom
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
# -*- encoding: binary -*-
|
||||
require_relative '../../spec_helper'
|
||||
require_relative 'shared/urandom'
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
describe "Random.raw_seed" do
|
||||
it_behaves_like :random_urandom, :raw_seed
|
||||
end
|
||||
end
|
||||
|
|
@ -33,7 +33,6 @@ describe "Range.new" do
|
|||
-> { Range.new(a, b) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "does not rescue exception raised in #<=> when compares the given start and end" do
|
||||
b = mock('a')
|
||||
a = mock('b')
|
||||
|
|
@ -41,7 +40,6 @@ describe "Range.new" do
|
|||
|
||||
-> { Range.new(a, b) }.should raise_error(RangeSpecs::ComparisonError)
|
||||
end
|
||||
end
|
||||
|
||||
describe "beginless/endless range" do
|
||||
ruby_version_is ""..."2.7" do
|
||||
|
|
|
|||
|
|
@ -25,17 +25,9 @@ describe "String#casecmp independent of case" do
|
|||
"abc".casecmp(other).should == 0
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "raises a TypeError if other can't be converted to a string" do
|
||||
-> { "abc".casecmp(mock('abc')) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "returns nil if other can't be converted to a string" do
|
||||
"abc".casecmp(mock('abc')).should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
it "returns nil if incompatible encodings" do
|
||||
"あれ".casecmp("れ".encode(Encoding::EUC_JP)).should be_nil
|
||||
|
|
@ -196,15 +188,7 @@ describe 'String#casecmp? independent of case' do
|
|||
"ß".casecmp?("ss").should be_true
|
||||
end
|
||||
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it "raises a TypeError if other can't be converted to a string" do
|
||||
-> { "abc".casecmp?(mock('abc')) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "returns nil if other can't be converted to a string" do
|
||||
"abc".casecmp?(mock('abc')).should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
require_relative '../../spec_helper'
|
||||
require_relative 'fixtures/classes'
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
describe "String#delete_prefix" do
|
||||
it "returns a copy of the string, with the given prefix removed" do
|
||||
'hello'.delete_prefix('hell').should == 'o'
|
||||
|
|
@ -80,4 +79,3 @@ ruby_version_is '2.5' do
|
|||
-> { ''.freeze.delete_prefix!('') }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
require_relative '../../spec_helper'
|
||||
require_relative 'fixtures/classes'
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
describe "String#delete_suffix" do
|
||||
it "returns a copy of the string, with the given suffix removed" do
|
||||
'hello'.delete_suffix('ello').should == 'h'
|
||||
|
|
@ -80,4 +79,3 @@ ruby_version_is '2.5' do
|
|||
-> { ''.freeze.delete_suffix!('') }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@ require_relative 'shared/chars'
|
|||
require_relative 'shared/grapheme_clusters'
|
||||
require_relative 'shared/each_char_without_block'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "String#each_grapheme_cluster" do
|
||||
it_behaves_like :string_chars, :each_grapheme_cluster
|
||||
it_behaves_like :string_grapheme_clusters, :each_grapheme_cluster
|
||||
it_behaves_like :string_each_char_without_block, :each_grapheme_cluster
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
require_relative 'shared/chars'
|
||||
require_relative 'shared/grapheme_clusters'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "String#grapheme_clusters" do
|
||||
it_behaves_like :string_chars, :grapheme_clusters
|
||||
it_behaves_like :string_grapheme_clusters, :grapheme_clusters
|
||||
|
|
@ -12,4 +11,3 @@ ruby_version_is "2.5" do
|
|||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -50,19 +50,10 @@ describe "String#%" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "formats single % character at the end as literal %" do
|
||||
("%" % []).should == "%"
|
||||
("foo%" % []).should == "foo%"
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "raises an error if single % appears at the end" do
|
||||
-> { ("%" % []) }.should raise_error(ArgumentError)
|
||||
-> { ("foo%" % [])}.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "formats single % character before a newline as literal %" do
|
||||
("%\n" % []).should == "%\n"
|
||||
|
|
|
|||
|
|
@ -54,19 +54,6 @@ describe :string_each_line, shared: true do
|
|||
a.should == ["one\ntwo\r\nthree"]
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.5' do
|
||||
it "yields paragraphs (broken by 2 or more successive newlines) when passed ''" do
|
||||
a = []
|
||||
"hello\nworld\n\n\nand\nuniverse\n\n\n\n\n".send(@method, '') { |s| a << s }
|
||||
a.should == ["hello\nworld\n\n\n", "and\nuniverse\n\n\n\n\n"]
|
||||
|
||||
a = []
|
||||
"hello\nworld\n\n\nand\nuniverse\n\n\n\n\ndog".send(@method, '') { |s| a << s }
|
||||
a.should == ["hello\nworld\n\n\n", "and\nuniverse\n\n\n\n\n", "dog"]
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
it "yields paragraphs (broken by 2 or more successive newlines) when passed '' and replaces multiple newlines with only two ones" do
|
||||
a = []
|
||||
"hello\nworld\n\n\nand\nuniverse\n\n\n\n\n".send(@method, '') { |s| a << s }
|
||||
|
|
@ -76,7 +63,6 @@ describe :string_each_line, shared: true do
|
|||
"hello\nworld\n\n\nand\nuniverse\n\n\n\n\ndog".send(@method, '') { |s| a << s }
|
||||
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n", "dog"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "uses $/" do
|
||||
before :each do
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ describe "String#start_with?" do
|
|||
"céréale".should.start_with?("cér")
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "supports regexps" do
|
||||
regexp = /[h1]/
|
||||
"hello".should.start_with?(regexp)
|
||||
|
|
@ -73,4 +72,3 @@ describe "String#start_with?" do
|
|||
$1.should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ describe 'String#-@' do
|
|||
output.should == 'foo'
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "returns the same object for equal unfrozen strings" do
|
||||
origin = "this is a string"
|
||||
dynamic = %w(this is a string).join(' ')
|
||||
|
|
@ -31,9 +30,8 @@ describe 'String#-@' do
|
|||
(-"unfrozen string").should equal(-"unfrozen string")
|
||||
(-"unfrozen string").should_not equal(-"another unfrozen string")
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5"..."2.6" do
|
||||
ruby_version_is ""..."2.6" do
|
||||
it "does not deduplicate already frozen strings" do
|
||||
dynamic = %w(this string is frozen).join(' ').freeze
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
require_relative '../../spec_helper'
|
||||
require_relative 'fixtures/classes'
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
describe "String#undump" do
|
||||
ruby_version_is ''...'2.7' do
|
||||
it "taints the result if self is tainted" do
|
||||
|
|
@ -450,4 +449,3 @@ ruby_version_is '2.5' do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ describe "Struct#hash" do
|
|||
s1.hash.should_not == s2.hash
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "returns different hashes for structs with different values when using keyword_init: true" do
|
||||
key = :"1 non symbol member"
|
||||
struct_class = Struct.new(key, keyword_init: true)
|
||||
|
|
@ -33,7 +32,6 @@ describe "Struct#hash" do
|
|||
t2 = struct_class.new(key => 2)
|
||||
t1.hash.should_not == t2.hash
|
||||
end
|
||||
end
|
||||
|
||||
it "allows for overriding methods in an included module" do
|
||||
mod = Module.new do
|
||||
|
|
|
|||
|
|
@ -62,17 +62,9 @@ describe "Struct.new" do
|
|||
-> { Struct.new(:animal, ['chris', 'evan']) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "raises a TypeError if an argument is a Hash" do
|
||||
-> { Struct.new(:animal, { name: 'chris' }) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "raises a ArgumentError if passed a Hash with an unknown key" do
|
||||
-> { Struct.new(:animal, { name: 'chris' }) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "raises ArgumentError when there is a duplicate member" do
|
||||
-> { Struct.new(:foo, :foo) }.should raise_error(ArgumentError, "duplicate member: foo")
|
||||
|
|
@ -147,7 +139,6 @@ describe "Struct.new" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
context "keyword_init: true option" do
|
||||
before :all do
|
||||
@struct_with_kwa = Struct.new(:name, :legs, keyword_init: true)
|
||||
|
|
@ -214,4 +205,3 @@ describe "Struct.new" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
ruby_version_is '2.5' do
|
||||
describe 'Thread#fetch' do
|
||||
describe 'with 2 arguments' do
|
||||
it 'returns the value of the fiber-local variable if value has been assigned' do
|
||||
|
|
@ -35,4 +34,3 @@ ruby_version_is '2.5' do
|
|||
-> { Thread.current.fetch(1, 2, 3) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,18 +1,10 @@
|
|||
require_relative '../../spec_helper'
|
||||
|
||||
describe "Thread.report_on_exception" do
|
||||
ruby_version_is "2.4"..."2.5" do
|
||||
it "defaults to false" do
|
||||
ruby_exe("p Thread.report_on_exception").should == "false\n"
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "defaults to true" do
|
||||
ruby_exe("p Thread.report_on_exception").should == "true\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Thread.report_on_exception=" do
|
||||
before :each do
|
||||
|
|
@ -33,7 +25,6 @@ describe "Thread.report_on_exception=" do
|
|||
end
|
||||
|
||||
describe "Thread#report_on_exception" do
|
||||
ruby_version_is "2.5" do
|
||||
it "returns true for the main Thread" do
|
||||
Thread.current.report_on_exception.should == true
|
||||
end
|
||||
|
|
@ -41,7 +32,6 @@ describe "Thread#report_on_exception" do
|
|||
it "returns true for new Threads" do
|
||||
Thread.new { Thread.current.report_on_exception }.value.should == true
|
||||
end
|
||||
end
|
||||
|
||||
it "returns whether the Thread will print a backtrace if it exits with an exception" do
|
||||
t = Thread.new { Thread.current.report_on_exception = true }
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
require_relative '../../spec_helper'
|
||||
require_relative 'shared/to_s'
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "Thread#to_s" do
|
||||
it_behaves_like :thread_to_s, :to_s
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -144,7 +144,6 @@ describe "Time.at" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
describe "passed [Time, Numeric, format]" do
|
||||
context ":nanosecond format" do
|
||||
it "treats second argument as nanoseconds" do
|
||||
|
|
@ -198,7 +197,6 @@ describe "Time.at" do
|
|||
Time.at(0, 123.500, :millisecond).nsec.should == 123500000
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
describe ":in keyword argument" do
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ describe :time_now, shared: true do
|
|||
end
|
||||
end
|
||||
|
||||
guard_not -> { platform_is :windows and ruby_version_is ""..."2.5" } do
|
||||
it "has at least microsecond precision" do
|
||||
times = []
|
||||
10_000.times do
|
||||
|
|
@ -32,4 +31,3 @@ describe :time_now, shared: true do
|
|||
times.select { |t| t % (expected * 10) == 0 }.size.should_not == times.size
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -55,11 +55,9 @@ describe 'TracePoint.new' do
|
|||
-> { TracePoint.new(o) {}}.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it 'expects to be called with a block' do
|
||||
-> { TracePoint.new(:line) }.should raise_error(ArgumentError, "must be called with a block")
|
||||
end
|
||||
end
|
||||
|
||||
it "raises a Argument error when the given argument doesn't match an event name" do
|
||||
-> { TracePoint.new(:test) }.should raise_error(ArgumentError, "unknown event: test")
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ describe "Warning.warn" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "is called by Kernel.warn" do
|
||||
Warning.should_receive(:warn).with("Chunky bacon!\n")
|
||||
verbose = $VERBOSE
|
||||
|
|
@ -63,4 +62,3 @@ describe "Warning.warn" do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -317,12 +317,10 @@ describe "A block" do
|
|||
@y.s(0) { 1 }.should == 1
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "may include a rescue clause" do
|
||||
eval("@y.z do raise ArgumentError; rescue ArgumentError; 7; end").should == 7
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "taking || arguments" do
|
||||
it "does not raise an exception when no values are yielded" do
|
||||
|
|
@ -333,12 +331,10 @@ describe "A block" do
|
|||
@y.s(0) { || 1 }.should == 1
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "may include a rescue clause" do
|
||||
eval('@y.z do || raise ArgumentError; rescue ArgumentError; 7; end').should == 7
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "taking |a| arguments" do
|
||||
it "assigns nil to the argument when no values are yielded" do
|
||||
|
|
@ -364,12 +360,10 @@ describe "A block" do
|
|||
@y.s([1, 2]) { |a| a }.should == [1, 2]
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "may include a rescue clause" do
|
||||
eval('@y.s(1) do |x| raise ArgumentError; rescue ArgumentError; 7; end').should == 7
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "taking |a, b| arguments" do
|
||||
it "assigns nil to the arguments when no values are yielded" do
|
||||
|
|
|
|||
|
|
@ -425,20 +425,10 @@ end
|
|||
|
||||
describe "top-level constant lookup" do
|
||||
context "on a class" do
|
||||
ruby_version_is "" ... "2.5" do
|
||||
it "searches Object successfully after searching other scopes" do
|
||||
-> {
|
||||
String::Hash.should == Hash
|
||||
}.should complain(/toplevel constant Hash referenced by/)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "does not search Object after searching other scopes" do
|
||||
-> { String::Hash }.should raise_error(NameError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "searches Object unsuccessfully when searches on a module" do
|
||||
-> { Enumerable::Hash }.should raise_error(NameError)
|
||||
|
|
|
|||
|
|
@ -756,17 +756,9 @@ describe "The defined? keyword for a scoped constant" do
|
|||
defined?(DefinedSpecs::String).should be_nil
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
it "returns 'constant' when a constant is defined on top-level but not on the class" do
|
||||
defined?(DefinedSpecs::Basic::String).should == 'constant'
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.5" do
|
||||
it "returns nil when a constant is defined on top-level but not on the class" do
|
||||
defined?(DefinedSpecs::Basic::String).should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
it "returns 'constant' if the scoped-scoped constant is defined" do
|
||||
defined?(DefinedSpecs::Child::A).should == "constant"
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue