This commit is contained in:
Benoit Daloze 2023-06-26 15:55:11 +02:00
parent f73fa29927
commit 515bd42144
428 changed files with 3666 additions and 9321 deletions

View File

@ -1,7 +1,7 @@
inherit_from: .rubocop_todo.yml inherit_from: .rubocop_todo.yml
AllCops: AllCops:
TargetRubyVersion: 2.7 TargetRubyVersion: 3.0
DisplayCopNames: true DisplayCopNames: true
Exclude: Exclude:
- command_line/fixtures/bad_syntax.rb - command_line/fixtures/bad_syntax.rb

View File

@ -138,12 +138,12 @@ Here is a list of the most commonly-used guards:
#### Version guards #### Version guards
```ruby ```ruby
ruby_version_is ""..."2.6" do ruby_version_is ""..."3.2" do
# Specs for RUBY_VERSION < 2.6 # Specs for RUBY_VERSION < 3.2
end end
ruby_version_is "2.6" do ruby_version_is "3.2" do
# Specs for RUBY_VERSION >= 2.6 # Specs for RUBY_VERSION >= 3.2
end end
``` ```
@ -191,11 +191,11 @@ end
#### Combining guards #### Combining guards
```ruby ```ruby
guard -> { platform_is :windows and ruby_version_is ""..."2.6" } do guard -> { platform_is :windows and ruby_version_is ""..."3.2" } do
# Windows and RUBY_VERSION < 2.6 # Windows and RUBY_VERSION < 3.2
end end
guard_not -> { platform_is :windows and ruby_version_is ""..."2.6" } do guard_not -> { platform_is :windows and ruby_version_is ""..."3.2" } do
# The opposite # The opposite
end end
``` ```

View File

@ -30,8 +30,8 @@ ruby/spec is known to be tested in these implementations for every commit:
* [Opal](https://github.com/opal/opal/tree/master/spec) * [Opal](https://github.com/opal/opal/tree/master/spec)
* [Artichoke](https://github.com/artichoke/spec/tree/artichoke-vendor) * [Artichoke](https://github.com/artichoke/spec/tree/artichoke-vendor)
ruby/spec describes the behavior of Ruby 2.7 and more recent Ruby versions. ruby/spec describes the behavior of Ruby 3.0 and more recent Ruby versions.
More precisely, every latest stable MRI release should [pass](https://github.com/ruby/spec/actions/workflows/ci.yml) all specs of ruby/spec (2.7.x, 3.0.x, 3.1.x, etc), and those are tested in CI. More precisely, every latest stable MRI release should [pass](https://github.com/ruby/spec/actions/workflows/ci.yml) all specs of ruby/spec (3.0.x, 3.1.x, 3.2.x, etc), and those are tested in CI.
### Synchronization with Ruby Implementations ### Synchronization with Ruby Implementations
@ -61,6 +61,7 @@ For older specs try these commits:
* Ruby 2.4.10 - [Suite](https://github.com/ruby/spec/commit/bce4f2b81d6c31db67cf4d023a0625ceadde59bd) using [MSpec](https://github.com/ruby/mspec/commit/e7eb8aa4c26495b7b461e687d950b96eb08b3ff2) * Ruby 2.4.10 - [Suite](https://github.com/ruby/spec/commit/bce4f2b81d6c31db67cf4d023a0625ceadde59bd) using [MSpec](https://github.com/ruby/mspec/commit/e7eb8aa4c26495b7b461e687d950b96eb08b3ff2)
* Ruby 2.5.9 - [Suite](https://github.com/ruby/spec/commit/c503335d3d9f6ec6ef24de60a0716c34af69b64f) using [MSpec](https://github.com/ruby/mspec/commit/0091e8a62e954717cd54641f935eaf1403692041) * Ruby 2.5.9 - [Suite](https://github.com/ruby/spec/commit/c503335d3d9f6ec6ef24de60a0716c34af69b64f) using [MSpec](https://github.com/ruby/mspec/commit/0091e8a62e954717cd54641f935eaf1403692041)
* Ruby 2.6.10 - [Suite](https://github.com/ruby/spec/commit/aaf998fb8c92c4e63ad423a2e7ca6e6921818c6e) using [MSpec](https://github.com/ruby/mspec/commit/5e36c684e9e2b92b1187589bba1df22c640a8661) * Ruby 2.6.10 - [Suite](https://github.com/ruby/spec/commit/aaf998fb8c92c4e63ad423a2e7ca6e6921818c6e) using [MSpec](https://github.com/ruby/mspec/commit/5e36c684e9e2b92b1187589bba1df22c640a8661)
* Ruby 2.7.8 - [Suite](https://github.com/ruby/spec/commit/93787e6035c925b593a9c0c6fb0e7e07a6f1df1f) using [MSpec](https://github.com/ruby/mspec/commit/1d8cf64722d8a7529f7cd205be5f16a89b7a67fd)
### Running the specs ### Running the specs

View File

@ -1,7 +1,6 @@
require_relative '../spec_helper' require_relative '../spec_helper'
ruby_version_is "3.0" do describe "The --backtrace-limit command line option" do
describe "The --backtrace-limit command line option" do
it "limits top-level backtraces to a given number of entries" do it "limits top-level backtraces to a given number of entries" do
file = fixture(__FILE__ , "backtrace.rb") file = fixture(__FILE__ , "backtrace.rb")
out = ruby_exe(file, options: "--backtrace-limit=2", args: "top 2>&1", exit_status: 1) out = ruby_exe(file, options: "--backtrace-limit=2", args: "top 2>&1", exit_status: 1)
@ -44,5 +43,4 @@ backtrace
/fixtures/backtrace.rb:29:in `<main>' /fixtures/backtrace.rb:29:in `<main>'
MSG MSG
end end
end
end end

View File

@ -1,16 +0,0 @@
require_relative '../../spec_helper'
require_relative 'shared/each_byte'
ruby_version_is ''...'3.0' do
describe "ARGF.bytes" do
before :each do
@verbose, $VERBOSE = $VERBOSE, nil
end
after :each do
$VERBOSE = @verbose
end
it_behaves_like :argf_each_byte, :bytes
end
end

View File

@ -1,16 +0,0 @@
require_relative '../../spec_helper'
require_relative 'shared/each_char'
ruby_version_is ''...'3.0' do
describe "ARGF.chars" do
before :each do
@verbose, $VERBOSE = $VERBOSE, nil
end
after :each do
$VERBOSE = @verbose
end
it_behaves_like :argf_each_char, :chars
end
end

View File

@ -1,16 +0,0 @@
require_relative '../../spec_helper'
require_relative 'shared/each_codepoint'
ruby_version_is ''...'3.0' do
describe "ARGF.codepoints" do
before :each do
@verbose, $VERBOSE = $VERBOSE, nil
end
after :each do
$VERBOSE = @verbose
end
it_behaves_like :argf_each_codepoint, :codepoints
end
end

View File

@ -1,16 +0,0 @@
require_relative '../../spec_helper'
require_relative 'shared/each_line'
ruby_version_is ''...'3.0' do
describe "ARGF.lines" do
before :each do
@verbose, $VERBOSE = $VERBOSE, nil
end
after :each do
$VERBOSE = @verbose
end
it_behaves_like :argf_each_line, :lines
end
end

View File

@ -50,15 +50,7 @@ describe "Array#drop" do
-> { [1, 2].drop(obj) }.should raise_error(TypeError) -> { [1, 2].drop(obj) }.should raise_error(TypeError)
end end
ruby_version_is ''...'3.0' do
it 'returns a subclass instance for Array subclasses' do
ArraySpecs::MyArray[1, 2, 3, 4, 5].drop(1).should be_an_instance_of(ArraySpecs::MyArray)
end
end
ruby_version_is '3.0' do
it 'returns a Array instance for Array subclasses' do it 'returns a Array instance for Array subclasses' do
ArraySpecs::MyArray[1, 2, 3, 4, 5].drop(1).should be_an_instance_of(Array) ArraySpecs::MyArray[1, 2, 3, 4, 5].drop(1).should be_an_instance_of(Array)
end end
end
end end

View File

@ -18,15 +18,7 @@ describe "Array#drop_while" do
[1, 2, 3, false, 5].drop_while { |n| n }.should == [false, 5] [1, 2, 3, false, 5].drop_while { |n| n }.should == [false, 5]
end end
ruby_version_is ''...'3.0' do
it 'returns a subclass instance for Array subclasses' do
ArraySpecs::MyArray[1, 2, 3, 4, 5].drop_while { |n| n < 4 }.should be_an_instance_of(ArraySpecs::MyArray)
end
end
ruby_version_is '3.0' do
it 'returns a Array instance for Array subclasses' do it 'returns a Array instance for Array subclasses' do
ArraySpecs::MyArray[1, 2, 3, 4, 5].drop_while { |n| n < 4 }.should be_an_instance_of(Array) ArraySpecs::MyArray[1, 2, 3, 4, 5].drop_while { |n| n < 4 }.should be_an_instance_of(Array)
end end
end
end end

View File

@ -75,17 +75,6 @@ describe "Array#flatten" do
[[obj]].flatten(1) [[obj]].flatten(1)
end end
ruby_version_is ''...'3.0' do
it "returns subclass instance for Array subclasses" do
ArraySpecs::MyArray[].flatten.should be_an_instance_of(ArraySpecs::MyArray)
ArraySpecs::MyArray[1, 2, 3].flatten.should be_an_instance_of(ArraySpecs::MyArray)
ArraySpecs::MyArray[1, [2], 3].flatten.should be_an_instance_of(ArraySpecs::MyArray)
ArraySpecs::MyArray[1, [2, 3], 4].flatten.should == ArraySpecs::MyArray[1, 2, 3, 4]
[ArraySpecs::MyArray[1, 2, 3]].flatten.should be_an_instance_of(Array)
end
end
ruby_version_is '3.0' do
it "returns Array instance for Array subclasses" do it "returns Array instance for Array subclasses" do
ArraySpecs::MyArray[].flatten.should be_an_instance_of(Array) ArraySpecs::MyArray[].flatten.should be_an_instance_of(Array)
ArraySpecs::MyArray[1, 2, 3].flatten.should be_an_instance_of(Array) ArraySpecs::MyArray[1, 2, 3].flatten.should be_an_instance_of(Array)
@ -93,7 +82,6 @@ describe "Array#flatten" do
ArraySpecs::MyArray[1, [2, 3], 4].flatten.should == [1, 2, 3, 4] ArraySpecs::MyArray[1, [2, 3], 4].flatten.should == [1, 2, 3, 4]
[ArraySpecs::MyArray[1, 2, 3]].flatten.should be_an_instance_of(Array) [ArraySpecs::MyArray[1, 2, 3]].flatten.should be_an_instance_of(Array)
end end
end
it "is not destructive" do it "is not destructive" do
ary = [1, [2, 3]] ary = [1, [2, 3]]

View File

@ -76,21 +76,11 @@ describe "Array#* with an integer" do
@array = ArraySpecs::MyArray[1, 2, 3, 4, 5] @array = ArraySpecs::MyArray[1, 2, 3, 4, 5]
end end
ruby_version_is ''...'3.0' do
it "returns a subclass instance" do
(@array * 0).should be_an_instance_of(ArraySpecs::MyArray)
(@array * 1).should be_an_instance_of(ArraySpecs::MyArray)
(@array * 2).should be_an_instance_of(ArraySpecs::MyArray)
end
end
ruby_version_is '3.0' do
it "returns an Array instance" do it "returns an Array instance" do
(@array * 0).should be_an_instance_of(Array) (@array * 0).should be_an_instance_of(Array)
(@array * 1).should be_an_instance_of(Array) (@array * 1).should be_an_instance_of(Array)
(@array * 2).should be_an_instance_of(Array) (@array * 2).should be_an_instance_of(Array)
end end
end
it "does not call #initialize on the subclass instance" do it "does not call #initialize on the subclass instance" do
(@array * 2).should == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] (@array * 2).should == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]

View File

@ -397,33 +397,6 @@ describe :array_slice, shared: true do
@array = ArraySpecs::MyArray[1, 2, 3, 4, 5] @array = ArraySpecs::MyArray[1, 2, 3, 4, 5]
end end
ruby_version_is ''...'3.0' do
it "returns a subclass instance with [n, m]" do
@array.send(@method, 0, 2).should be_an_instance_of(ArraySpecs::MyArray)
end
it "returns a subclass instance with [-n, m]" do
@array.send(@method, -3, 2).should be_an_instance_of(ArraySpecs::MyArray)
end
it "returns a subclass instance with [n..m]" do
@array.send(@method, 1..3).should be_an_instance_of(ArraySpecs::MyArray)
end
it "returns a subclass instance with [n...m]" do
@array.send(@method, 1...3).should be_an_instance_of(ArraySpecs::MyArray)
end
it "returns a subclass instance with [-n..-m]" do
@array.send(@method, -3..-1).should be_an_instance_of(ArraySpecs::MyArray)
end
it "returns a subclass instance with [-n...-m]" do
@array.send(@method, -3...-1).should be_an_instance_of(ArraySpecs::MyArray)
end
end
ruby_version_is '3.0' do
it "returns a Array instance with [n, m]" do it "returns a Array instance with [n, m]" do
@array.send(@method, 0, 2).should be_an_instance_of(Array) @array.send(@method, 0, 2).should be_an_instance_of(Array)
end end
@ -447,7 +420,6 @@ describe :array_slice, shared: true do
it "returns a Array instance with [-n...-m]" do it "returns a Array instance with [-n...-m]" do
@array.send(@method, -3...-1).should be_an_instance_of(Array) @array.send(@method, -3...-1).should be_an_instance_of(Array)
end end
end
it "returns an empty array when m == n with [m...n]" do it "returns an empty array when m == n with [m...n]" do
@array.send(@method, 1...1).should == [] @array.send(@method, 1...1).should == []
@ -534,7 +506,6 @@ describe :array_slice, shared: true do
a.send(@method, eval("(-9...)")).should == nil a.send(@method, eval("(-9...)")).should == nil
end end
ruby_version_is "3.0" do
describe "can be sliced with Enumerator::ArithmeticSequence" do describe "can be sliced with Enumerator::ArithmeticSequence" do
before :each do before :each do
@array = [0, 1, 2, 3, 4, 5] @array = [0, 1, 2, 3, 4, 5]
@ -768,7 +739,6 @@ describe :array_slice, shared: true do
-> { @array.send(@method, eval("(7..).step(2)")) }.should raise_error(RangeError) -> { @array.send(@method, eval("(7..).step(2)")) }.should raise_error(RangeError)
end end
end end
end
it "can accept beginless ranges" do it "can accept beginless ranges" do
a = [0, 1, 2, 3, 4, 5] a = [0, 1, 2, 3, 4, 5]

View File

@ -187,33 +187,6 @@ describe "Array#slice!" do
@array = ArraySpecs::MyArray[1, 2, 3, 4, 5] @array = ArraySpecs::MyArray[1, 2, 3, 4, 5]
end end
ruby_version_is ''...'3.0' do
it "returns a subclass instance with [n, m]" do
@array.slice!(0, 2).should be_an_instance_of(ArraySpecs::MyArray)
end
it "returns a subclass instance with [-n, m]" do
@array.slice!(-3, 2).should be_an_instance_of(ArraySpecs::MyArray)
end
it "returns a subclass instance with [n..m]" do
@array.slice!(1..3).should be_an_instance_of(ArraySpecs::MyArray)
end
it "returns a subclass instance with [n...m]" do
@array.slice!(1...3).should be_an_instance_of(ArraySpecs::MyArray)
end
it "returns a subclass instance with [-n..-m]" do
@array.slice!(-3..-1).should be_an_instance_of(ArraySpecs::MyArray)
end
it "returns a subclass instance with [-n...-m]" do
@array.slice!(-3...-1).should be_an_instance_of(ArraySpecs::MyArray)
end
end
ruby_version_is '3.0' do
it "returns a Array instance with [n, m]" do it "returns a Array instance with [n, m]" do
@array.slice!(0, 2).should be_an_instance_of(Array) @array.slice!(0, 2).should be_an_instance_of(Array)
end end
@ -238,7 +211,6 @@ describe "Array#slice!" do
@array.slice!(-3...-1).should be_an_instance_of(Array) @array.slice!(-3...-1).should be_an_instance_of(Array)
end end
end end
end
end end
describe "Array#slice" do describe "Array#slice" do

View File

@ -26,15 +26,7 @@ describe "Array#take" do
->{ [1].take(-3) }.should raise_error(ArgumentError) ->{ [1].take(-3) }.should raise_error(ArgumentError)
end end
ruby_version_is ''...'3.0' do
it 'returns a subclass instance for Array subclasses' do
ArraySpecs::MyArray[1, 2, 3, 4, 5].take(1).should be_an_instance_of(ArraySpecs::MyArray)
end
end
ruby_version_is '3.0' do
it 'returns a Array instance for Array subclasses' do it 'returns a Array instance for Array subclasses' do
ArraySpecs::MyArray[1, 2, 3, 4, 5].take(1).should be_an_instance_of(Array) ArraySpecs::MyArray[1, 2, 3, 4, 5].take(1).should be_an_instance_of(Array)
end end
end
end end

View File

@ -15,17 +15,9 @@ describe "Array#take_while" do
[1, 2, false, 4].take_while{ |element| element }.should == [1, 2] [1, 2, false, 4].take_while{ |element| element }.should == [1, 2]
end end
ruby_version_is ''...'3.0' do
it 'returns a subclass instance for Array subclasses' do
ArraySpecs::MyArray[1, 2, 3, 4, 5].take_while { |n| n < 4 }.should be_an_instance_of(ArraySpecs::MyArray)
end
end
ruby_version_is '3.0' do
it 'returns a Array instance for Array subclasses' do it 'returns a Array instance for Array subclasses' do
ArraySpecs::MyArray[1, 2, 3, 4, 5].take_while { |n| n < 4 }.should be_an_instance_of(Array) ArraySpecs::MyArray[1, 2, 3, 4, 5].take_while { |n| n < 4 }.should be_an_instance_of(Array)
end end
end
end end
describe "Array#take_while" do describe "Array#take_while" do

View File

@ -85,17 +85,9 @@ describe "Array#uniq" do
[false, nil, 42].uniq { :bar }.should == [false] [false, nil, 42].uniq { :bar }.should == [false]
end end
ruby_version_is ''...'3.0' do
it "returns subclass instance on Array subclasses" do
ArraySpecs::MyArray[1, 2, 3].uniq.should be_an_instance_of(ArraySpecs::MyArray)
end
end
ruby_version_is '3.0' do
it "returns Array instance on Array subclasses" do it "returns Array instance on Array subclasses" do
ArraySpecs::MyArray[1, 2, 3].uniq.should be_an_instance_of(Array) ArraySpecs::MyArray[1, 2, 3].uniq.should be_an_instance_of(Array)
end end
end
it "properly handles an identical item even when its #eql? isn't reflexive" do it "properly handles an identical item even when its #eql? isn't reflexive" do
x = mock('x') x = mock('x')

View File

@ -23,34 +23,6 @@ describe "Binding#eval" do
bind2.local_variables.should == [] bind2.local_variables.should == []
end end
ruby_version_is ""..."3.0" do
it "inherits __LINE__ from the enclosing scope" do
obj = BindingSpecs::Demo.new(1)
bind = obj.get_binding
suppress_warning {bind.eval("__LINE__")}.should == obj.get_line_of_binding
end
it "preserves __LINE__ across multiple calls to eval" do
obj = BindingSpecs::Demo.new(1)
bind = obj.get_binding
suppress_warning {bind.eval("__LINE__")}.should == obj.get_line_of_binding
suppress_warning {bind.eval("__LINE__")}.should == obj.get_line_of_binding
end
it "increments __LINE__ on each line of a multiline eval" do
obj = BindingSpecs::Demo.new(1)
bind = obj.get_binding
suppress_warning {bind.eval("#foo\n__LINE__")}.should == obj.get_line_of_binding + 1
end
it "inherits __LINE__ from the enclosing scope even if the Binding is created with #send" do
obj = BindingSpecs::Demo.new(1)
bind, line = obj.get_binding_with_send_and_line
suppress_warning {bind.eval("__LINE__")}.should == line
end
end
ruby_version_is "3.0" do
it "starts with line 1 if single argument is given" do it "starts with line 1 if single argument is given" do
obj = BindingSpecs::Demo.new(1) obj = BindingSpecs::Demo.new(1)
bind = obj.get_binding bind = obj.get_binding
@ -75,7 +47,6 @@ describe "Binding#eval" do
bind, line = obj.get_binding_with_send_and_line bind, line = obj.get_binding_with_send_and_line
bind.eval("__LINE__").should == 1 bind.eval("__LINE__").should == 1
end end
end
it "starts with a __LINE__ of 1 if a filename is passed" do it "starts with a __LINE__ of 1 if a filename is passed" do
bind = BindingSpecs::Demo.new(1).get_binding bind = BindingSpecs::Demo.new(1).get_binding
@ -89,21 +60,6 @@ describe "Binding#eval" do
bind.eval("#foo\n__LINE__", "(test)", 88).should == 89 bind.eval("#foo\n__LINE__", "(test)", 88).should == 89
end end
ruby_version_is ""..."3.0" do
it "inherits __FILE__ from the enclosing scope" do
obj = BindingSpecs::Demo.new(1)
bind = obj.get_binding
suppress_warning { bind.eval("__FILE__") }.should == obj.get_file_of_binding
end
it "inherits __LINE__ from the enclosing scope" do
obj = BindingSpecs::Demo.new(1)
bind, line = obj.get_binding_and_line
suppress_warning { bind.eval("__LINE__") }.should == line
end
end
ruby_version_is "3.0" do
it "uses (eval) as __FILE__ if single argument given" do it "uses (eval) as __FILE__ if single argument given" do
obj = BindingSpecs::Demo.new(1) obj = BindingSpecs::Demo.new(1)
bind = obj.get_binding bind = obj.get_binding
@ -115,7 +71,6 @@ describe "Binding#eval" do
bind = obj.get_binding bind = obj.get_binding
suppress_warning { bind.eval("__LINE__") }.should == 1 suppress_warning { bind.eval("__LINE__") }.should == 1
end end
end
it "uses the __FILE__ that is passed in" do it "uses the __FILE__ that is passed in" do
bind = BindingSpecs::Demo.new(1).get_binding bind = BindingSpecs::Demo.new(1).get_binding

View File

@ -1,20 +1,6 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
ruby_version_is ''...'3.0' do ruby_version_is ''...'3.2' do
describe "Data" do
it "is a subclass of Object" do
suppress_warning do
Data.superclass.should == Object
end
end
it "is deprecated" do
-> { Data }.should complain(/constant ::Data is deprecated/)
end
end
end
ruby_version_is '3.0'...'3.2' do
describe "Data" do describe "Data" do
it "does not exist anymore" do it "does not exist anymore" do
Object.should_not have_constant(:Data) Object.should_not have_constant(:Data)

View File

@ -260,7 +260,7 @@ describe "Dir.glob" do
Dir.glob('**/.*', base: "deeply/nested").sort.should == expected Dir.glob('**/.*', base: "deeply/nested").sort.should == expected
end end
# 2.7 and 3.0 include a "." entry for every dir: ["directory/.", "directory/structure/.", ...] # < 3.1 include a "." entry for every dir: ["directory/.", "directory/structure/.", ...]
ruby_version_is '3.1' do ruby_version_is '3.1' do
it "handles **/.* with base keyword argument and FNM_DOTMATCH" do it "handles **/.* with base keyword argument and FNM_DOTMATCH" do
expected = %w[ expected = %w[

View File

@ -27,7 +27,6 @@ describe :dir_glob, shared: true do
-> {Dir.send(@method, "file_o*\0file_t*")}.should raise_error ArgumentError, /nul-separated/ -> {Dir.send(@method, "file_o*\0file_t*")}.should raise_error ArgumentError, /nul-separated/
end end
ruby_version_is "3.0" do
it "result is sorted by default" do it "result is sorted by default" do
result = Dir.send(@method, '*') result = Dir.send(@method, '*')
result.should == result.sort result.should == result.sort
@ -42,9 +41,8 @@ describe :dir_glob, shared: true do
result = Dir.send(@method,'*', sort: false) result = Dir.send(@method,'*', sort: false)
result.sort.should == Dir.send(@method, '*').sort result.sort.should == Dir.send(@method, '*').sort
end end
end
ruby_version_is "3.0"..."3.1" do ruby_version_is ""..."3.1" do
it "result is sorted with any non false value of sort:" do it "result is sorted with any non false value of sort:" do
result = Dir.send(@method, '*', sort: 0) result = Dir.send(@method, '*', sort: 0)
result.should == result.sort result.should == result.sort

View File

@ -18,13 +18,11 @@ describe "Encoding.default_external" do
Encoding.default_external.should == Encoding::SHIFT_JIS Encoding.default_external.should == Encoding::SHIFT_JIS
end end
ruby_version_is "3.0" do
platform_is :windows do platform_is :windows do
it 'is UTF-8 by default on Windows' do it 'is UTF-8 by default on Windows' do
Encoding.default_external.should == Encoding::UTF_8 Encoding.default_external.should == Encoding::UTF_8
end end
end end
end
end end
describe "Encoding.default_external=" do describe "Encoding.default_external=" do

View File

@ -40,20 +40,6 @@ describe "Enumerable#grep" do
$~.should == nil $~.should == nil
end end
ruby_version_is ""..."3.0.0" do
it "sets $~ to the last match when given no block" do
"z" =~ /z/ # Reset $~
["abc", "def"].grep(/b/).should == ["abc"]
# Set by the failed match of "def"
$~.should == nil
["abc", "def"].grep(/e/)
$&.should == "e"
end
end
ruby_version_is "3.0.0" do
it "does not set $~ when given no block" do it "does not set $~ when given no block" do
"z" =~ /z/ # Reset $~ "z" =~ /z/ # Reset $~
["abc", "def"].grep(/b/).should == ["abc"] ["abc", "def"].grep(/b/).should == ["abc"]
@ -77,7 +63,6 @@ describe "Enumerable#grep" do
end end
[o].grep(/ll/).first.should.equal?(o) [o].grep(/ll/).first.should.equal?(o)
end end
end
describe "with a block" do describe "with a block" do
before :each do before :each do

View File

@ -20,20 +20,6 @@ describe "Enumerable#grep_v" do
$&.should == "e" $&.should == "e"
end end
ruby_version_is ""..."3.0.0" do
it "sets $~ to the last match when given no block" do
"z" =~ /z/ # Reset $~
["abc", "def"].grep_v(/e/).should == ["abc"]
# Set by the match of "def"
$&.should == "e"
["abc", "def"].grep_v(/b/)
$&.should == nil
end
end
ruby_version_is "3.0.0" do
it "does not set $~ when given no block" do it "does not set $~ when given no block" do
"z" =~ /z/ # Reset $~ "z" =~ /z/ # Reset $~
["abc", "def"].grep_v(/e/).should == ["abc"] ["abc", "def"].grep_v(/e/).should == ["abc"]
@ -57,7 +43,6 @@ describe "Enumerable#grep_v" do
end end
[o].grep_v(/mm/).first.should.equal?(o) [o].grep_v(/mm/).first.should.equal?(o)
end end
end
describe "without block" do describe "without block" do
it "returns an Array of matched elements" do it "returns an Array of matched elements" do

View File

@ -11,14 +11,6 @@ describe "Enumerator#initialize" do
Enumerator.should have_private_instance_method(:initialize, false) Enumerator.should have_private_instance_method(:initialize, false)
end end
ruby_version_is ''...'3.0' do
it "returns self when given an object" do
suppress_warning do
@uninitialized.send(:initialize, Object.new).should equal(@uninitialized)
end
end
end
it "returns self when given a block" do it "returns self when given a block" do
@uninitialized.send(:initialize) {}.should equal(@uninitialized) @uninitialized.send(:initialize) {}.should equal(@uninitialized)
end end

View File

@ -2,54 +2,11 @@ require_relative '../../spec_helper'
describe "Enumerator.new" do describe "Enumerator.new" do
context "no block given" do context "no block given" do
ruby_version_is '3.0' do
it "raises" do it "raises" do
-> { Enumerator.new(1, :upto, 3) }.should raise_error(ArgumentError) -> { Enumerator.new(1, :upto, 3) }.should raise_error(ArgumentError)
end end
end end
ruby_version_is ''...'3.0' do
it "creates a new custom enumerator with the given object, iterator and arguments" do
enum = suppress_warning { Enumerator.new(1, :upto, 3) }
enum.should be_an_instance_of(Enumerator)
end
it "creates a new custom enumerator that responds to #each" do
enum = suppress_warning { Enumerator.new(1, :upto, 3) }
enum.respond_to?(:each).should == true
end
it "creates a new custom enumerator that runs correctly" do
suppress_warning { Enumerator.new(1, :upto, 3) }.map{ |x| x }.should == [1,2,3]
end
it "aliases the second argument to :each" do
suppress_warning { Enumerator.new(1..2) }.to_a.should ==
suppress_warning { Enumerator.new(1..2, :each) }.to_a
end
it "doesn't check for the presence of the iterator method" do
suppress_warning { Enumerator.new(nil) }.should be_an_instance_of(Enumerator)
end
it "uses the latest define iterator method" do
class StrangeEach
def each
yield :foo
end
end
enum = suppress_warning { Enumerator.new(StrangeEach.new) }
enum.to_a.should == [:foo]
class StrangeEach
def each
yield :bar
end
end
enum.to_a.should == [:bar]
end
end
end
context "when passed a block" do context "when passed a block" do
it "defines iteration with block, yielder argument and calling << method" do it "defines iteration with block, yielder argument and calling << method" do
enum = Enumerator.new do |yielder| enum = Enumerator.new do |yielder|

View File

@ -30,12 +30,10 @@ describe "ENV.delete" do
ScratchPad.recorded.should == "foo" ScratchPad.recorded.should == "foo"
end end
ruby_version_is "3.0" do
it "returns the result of given block if the named environment variable does not exist" do it "returns the result of given block if the named environment variable does not exist" do
ENV.delete("foo") ENV.delete("foo")
ENV.delete("foo") { |name| "bar" }.should == "bar" ENV.delete("foo") { |name| "bar" }.should == "bar"
end end
end
it "does not evaluate the block if the environment variable exists" do it "does not evaluate the block if the environment variable exists" do
ENV["foo"] = "bar" ENV["foo"] = "bar"

View File

@ -1,8 +1,7 @@
require_relative 'spec_helper' require_relative 'spec_helper'
require_relative 'shared/to_hash' require_relative 'shared/to_hash'
ruby_version_is "3.0" do describe "ENV.except" do
describe "ENV.except" do
before do before do
@orig_hash = ENV.to_hash @orig_hash = ENV.to_hash
end end
@ -32,5 +31,4 @@ ruby_version_is "3.0" do
ENV.except('one', 'three').should == { 'two' => '2' } ENV.except('one', 'three').should == { 'two' => '2' }
end end
end
end end

View File

@ -1,14 +0,0 @@
require_relative '../../spec_helper'
require_relative 'shared/key'
ruby_version_is ''...'3.0' do
describe "ENV.index" do
it_behaves_like :env_key, :index
it "warns about deprecation" do
-> do
ENV.index("foo")
end.should complain(/warning: ENV.index is deprecated; use ENV.key/)
end
end
end

View File

@ -1 +0,0 @@
require_relative '../../spec_helper'

View File

@ -1 +0,0 @@
require_relative '../../spec_helper'

View File

@ -6,7 +6,10 @@ describe "ENV.to_a" do
a = ENV.to_a a = ENV.to_a
a.is_a?(Array).should == true a.is_a?(Array).should == true
a.size.should == ENV.size a.size.should == ENV.size
ENV.each_pair { |k, v| a.should include([k, v])} a.each { |k,v| ENV[k].should == v }
a.first.should.is_a?(Array)
a.first.size.should == 2
end end
it "returns the entries in the locale encoding" do it "returns the entries in the locale encoding" do

View File

@ -125,7 +125,6 @@ describe "NoMethodError#message" do
end end
end end
ruby_version_is "3.0" do
it "uses #name to display the receiver if it is a class or a module" do it "uses #name to display the receiver if it is a class or a module" do
klass = Class.new { def self.name; "MyClass"; end } klass = Class.new { def self.name; "MyClass"; end }
begin begin
@ -141,7 +140,6 @@ describe "NoMethodError#message" do
error.message.lines.first.chomp.should =~ /^undefined method `foo' for / error.message.lines.first.chomp.should =~ /^undefined method `foo' for /
end end
end end
end
end end
describe "NoMethodError#dup" do describe "NoMethodError#dup" do

View File

@ -1,10 +1,9 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
require_relative 'shared/blocking' require_relative 'shared/blocking'
ruby_version_is "3.0" do require "fiber"
require "fiber"
describe "Fiber.blocking?" do describe "Fiber.blocking?" do
it_behaves_like :non_blocking_fiber, -> { Fiber.blocking? } it_behaves_like :non_blocking_fiber, -> { Fiber.blocking? }
context "when fiber is blocking" do context "when fiber is blocking" do
@ -30,9 +29,9 @@ ruby_version_is "3.0" do
end end
end end
end end
end end
describe "Fiber#blocking?" do describe "Fiber#blocking?" do
it_behaves_like :non_blocking_fiber, -> { Fiber.current.blocking? } it_behaves_like :non_blocking_fiber, -> { Fiber.current.blocking? }
context "when fiber is blocking" do context "when fiber is blocking" do
@ -58,7 +57,6 @@ ruby_version_is "3.0" do
end end
end end
end end
end
end end
ruby_version_is "3.2" do ruby_version_is "3.2" do

View File

@ -18,12 +18,10 @@ describe "Fiber#inspect" do
inspected.should =~ /\A#<Fiber:0x\h+ .+ \(resumed\)>\z/ inspected.should =~ /\A#<Fiber:0x\h+ .+ \(resumed\)>\z/
end end
ruby_version_is "3.0" do
it "is resumed for a Fiber which was transferred" do it "is resumed for a Fiber which was transferred" do
inspected = Fiber.new { Fiber.current.inspect }.transfer inspected = Fiber.new { Fiber.current.inspect }.transfer
inspected.should =~ /\A#<Fiber:0x\h+ .+ \(resumed\)>\z/ inspected.should =~ /\A#<Fiber:0x\h+ .+ \(resumed\)>\z/
end end
end
it "is suspended for a Fiber which was resumed and yielded" do it "is suspended for a Fiber which was resumed and yielded" do
inspected = Fiber.new { Fiber.yield }.tap(&:resume).inspect inspected = Fiber.new { Fiber.yield }.tap(&:resume).inspect

View File

@ -94,20 +94,7 @@ describe "Fiber#raise" do
end end
ruby_version_is ""..."3.0" do describe "Fiber#raise" do
describe "Fiber#raise" do
it "raises a FiberError if invoked on a transferring Fiber" do
require "fiber"
root = Fiber.current
fiber = Fiber.new { root.transfer }
fiber.transfer
-> { fiber.raise }.should raise_error(FiberError, "cannot resume transferred Fiber")
end
end
end
ruby_version_is "3.0" do
describe "Fiber#raise" do
it "transfers and raises on a transferring fiber" do it "transfers and raises on a transferring fiber" do
require "fiber" require "fiber"
root = Fiber.current root = Fiber.current
@ -115,5 +102,4 @@ ruby_version_is "3.0" do
fiber.transfer fiber.transfer
-> { fiber.raise "msg" }.should raise_error(RuntimeError, "msg") -> { fiber.raise "msg" }.should raise_error(RuntimeError, "msg")
end end
end
end end

View File

@ -28,19 +28,10 @@ describe "Fiber#resume" do
fiber.resume :second fiber.resume :second
end end
ruby_version_is '3.0' do
it "raises a FiberError if the Fiber tries to resume itself" do it "raises a FiberError if the Fiber tries to resume itself" do
fiber = Fiber.new { fiber.resume } fiber = Fiber.new { fiber.resume }
-> { fiber.resume }.should raise_error(FiberError, /current fiber/) -> { fiber.resume }.should raise_error(FiberError, /current fiber/)
end end
end
ruby_version_is '' ... '3.0' do
it "raises a FiberError if the Fiber tries to resume itself" do
fiber = Fiber.new { fiber.resume }
-> { fiber.resume }.should raise_error(FiberError, /double resume/)
end
end
it "returns control to the calling Fiber if called from one" do it "returns control to the calling Fiber if called from one" do
fiber1 = Fiber.new { :fiber1 } fiber1 = Fiber.new { :fiber1 }

View File

@ -168,7 +168,6 @@ describe "File.new" do
File.should.exist?(@file) File.should.exist?(@file)
end end
ruby_version_is "3.0" do
it "accepts options as a keyword argument" do it "accepts options as a keyword argument" do
@fh = File.new(@file, 'w', 0755, flags: @flags) @fh = File.new(@file, 'w', 0755, flags: @flags)
@fh.should be_kind_of(File) @fh.should be_kind_of(File)
@ -178,7 +177,6 @@ describe "File.new" do
@fh = File.new(@file, 'w', 0755, {flags: @flags}) @fh = File.new(@file, 'w', 0755, {flags: @flags})
}.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)")
end end
end
it "bitwise-ORs mode and flags option" do it "bitwise-ORs mode and flags option" do
-> { -> {

View File

@ -565,7 +565,6 @@ describe "File.open" do
File.open(@file, 'wb+') {|f| f.external_encoding.should == Encoding::BINARY} File.open(@file, 'wb+') {|f| f.external_encoding.should == Encoding::BINARY}
end end
ruby_version_is "3.0" do
it "accepts options as a keyword argument" do it "accepts options as a keyword argument" do
@fh = File.open(@file, 'w', 0755, flags: File::CREAT) @fh = File.open(@file, 'w', 0755, flags: File::CREAT)
@fh.should be_an_instance_of(File) @fh.should be_an_instance_of(File)
@ -574,7 +573,6 @@ describe "File.open" do
File.open(@file, 'w', 0755, {flags: File::CREAT}) File.open(@file, 'w', 0755, {flags: File::CREAT})
}.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)")
end end
end
it "uses the second argument as an options Hash" do it "uses the second argument as an options Hash" do
@fh = File.open(@file, mode: "r") @fh = File.open(@file, mode: "r")

View File

@ -1,7 +1,6 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
ruby_version_is "3.0" do describe "GC.auto_compact" do
describe "GC.auto_compact" do
it "can set and get a boolean value" do it "can set and get a boolean value" do
begin begin
GC.auto_compact = GC.auto_compact GC.auto_compact = GC.auto_compact
@ -22,5 +21,4 @@ ruby_version_is "3.0" do
GC.auto_compact = original GC.auto_compact = original
end end
end end
end
end end

View File

@ -1,7 +1,6 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
ruby_version_is "3.0" do describe "Hash#except" do
describe "Hash#except" do
before :each do before :each do
@hash = { a: 1, b: 2, c: 3 } @hash = { a: 1, b: 2, c: 3 }
end end
@ -30,5 +29,4 @@ ruby_version_is "3.0" do
r.class.should == Hash r.class.should == Hash
r.default.should == nil r.default.should == nil
end end
end
end end

View File

@ -1,9 +0,0 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
require_relative 'shared/index'
ruby_version_is ''...'3.0' do
describe "Hash#index" do
it_behaves_like :hash_index, :index
end
end

View File

@ -21,24 +21,6 @@ describe :hash_each, shared: true do
ary.sort.should == ["a", "b", "c"] ary.sort.should == ["a", "b", "c"]
end end
ruby_version_is ""..."3.0" 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
end
ScratchPad.record([])
{ "a" => 1 }.send(@method, &obj.method(:foo))
ScratchPad.recorded.should == ["a", 1]
ScratchPad.record([])
{ "a" => 1 }.send(@method, &-> key, value { ScratchPad << key << value })
ScratchPad.recorded.should == ["a", 1]
end
end
ruby_version_is "3.0" do
it "always yields an Array of 2 elements, even when given a callable of arity 2" do it "always yields an Array of 2 elements, even when given a callable of arity 2" do
obj = Object.new obj = Object.new
def obj.foo(key, value) def obj.foo(key, value)
@ -52,7 +34,6 @@ describe :hash_each, shared: true do
{ "a" => 1 }.send(@method, &-> key, value { }) { "a" => 1 }.send(@method, &-> key, value { })
}.should raise_error(ArgumentError) }.should raise_error(ArgumentError)
end end
end
it "yields an Array of 2 elements when given a callable of arity 1" do it "yields an Array of 2 elements when given a callable of arity 1" do
obj = Object.new obj = Object.new

View File

@ -1,90 +0,0 @@
describe :hash_equal, shared: true do
it "does not compare values when keys don't match" do
value = mock('x')
value.should_not_receive(:==)
value.should_not_receive(:eql?)
{ 1 => value }.send(@method, { 2 => value }).should be_false
end
it "returns false when the numbers of keys differ without comparing any elements" do
obj = mock('x')
h = { obj => obj }
obj.should_not_receive(:==)
obj.should_not_receive(:eql?)
{}.send(@method, h).should be_false
h.send(@method, {}).should be_false
end
it "first compares keys via hash" do
x = mock('x')
x.should_receive(:hash).and_return(0)
y = mock('y')
y.should_receive(:hash).and_return(0)
{ x => 1 }.send(@method, { y => 1 }).should be_false
end
it "does not compare keys with different hash codes via eql?" do
x = mock('x')
y = mock('y')
x.should_not_receive(:eql?)
y.should_not_receive(:eql?)
x.should_receive(:hash).and_return(0)
y.should_receive(:hash).and_return(1)
def x.hash() 0 end
def y.hash() 1 end
{ x => 1 }.send(@method, { y => 1 }).should be_false
end
it "computes equality for recursive hashes" do
h = {}
h[:a] = h
h.send(@method, h[:a]).should be_true
(h == h[:a]).should be_true
end
it "computes equality for complex recursive hashes" do
a, b = {}, {}
a.merge! self: a, other: b
b.merge! self: b, other: a
a.send(@method, b).should be_true # they both have the same structure!
c = {}
c.merge! other: c, self: c
c.send(@method, a).should be_true # subtle, but they both have the same structure!
a[:delta] = c[:delta] = a
c.send(@method, a).should be_false # not quite the same structure, as a[:other][:delta] = nil
c[:delta] = 42
c.send(@method, a).should be_false
a[:delta] = 42
c.send(@method, a).should be_false
b[:delta] = 42
c.send(@method, a).should be_true
end
it "computes equality for recursive hashes & arrays" do
x, y, z = [], [], []
a, b, c = {foo: x, bar: 42}, {foo: y, bar: 42}, {foo: z, bar: 42}
x << a
y << c
z << b
b.send(@method, c).should be_true # they clearly have the same structure!
y.send(@method, z).should be_true
a.send(@method, b).should be_true # subtle, but they both have the same structure!
x.send(@method, y).should be_true
y << x
y.send(@method, z).should be_false
z << x
y.send(@method, z).should be_true
a[:foo], a[:bar] = a[:bar], a[:foo]
a.send(@method, b).should be_false
b[:bar] = b[:foo]
b.send(@method, c).should be_false
end
end

View File

@ -26,14 +26,4 @@ describe "Hash#to_a" do
ent.should be_kind_of(Array) ent.should be_kind_of(Array)
ent.should == pairs ent.should == pairs
end end
ruby_version_is ''...'3.0' do
it "returns a not tainted array if self is tainted" do
{}.taint.to_a.tainted?.should be_false
end
it "returns a trusted array if self is untrusted" do
{}.untrust.to_a.untrusted?.should be_false
end
end
end end

View File

@ -19,13 +19,6 @@ describe "Hash#to_proc" do
@proc = @hash.to_proc @proc = @hash.to_proc
end end
ruby_version_is ""..."3.0" do
it "is not a lambda" do
@proc.should_not.lambda?
end
end
ruby_version_is "3.0" do
it "is a lambda" do it "is a lambda" do
@proc.should.lambda? @proc.should.lambda?
end end
@ -33,7 +26,6 @@ describe "Hash#to_proc" do
it "has an arity of 1" do it "has an arity of 1" do
@proc.arity.should == 1 @proc.arity.should == 1
end end
end
it "raises ArgumentError if not passed exactly one argument" do it "raises ArgumentError if not passed exactly one argument" do
-> { -> {

View File

@ -43,7 +43,6 @@ describe "Hash#transform_keys" do
r.class.should == Hash r.class.should == Hash
end end
ruby_version_is "3.0" do
it "allows a hash argument" do it "allows a hash argument" do
@hash.transform_keys({ a: :A, b: :B, c: :C }).should == { A: 1, B: 2, C: 3 } @hash.transform_keys({ a: :A, b: :B, c: :C }).should == { A: 1, B: 2, C: 3 }
end end
@ -55,7 +54,6 @@ describe "Hash#transform_keys" do
it "allows a combination of hash and block argument" do it "allows a combination of hash and block argument" do
@hash.transform_keys({ a: :A }, &:to_s).should == { A: 1, 'b' => 2, 'c' => 3 } @hash.transform_keys({ a: :A }, &:to_s).should == { A: 1, 'b' => 2, 'c' => 3 }
end end
end
end end
describe "Hash#transform_keys!" do describe "Hash#transform_keys!" do
@ -111,12 +109,10 @@ describe "Hash#transform_keys!" do
end end
end end
ruby_version_is "3.0" do
it "allows a hash argument" do it "allows a hash argument" do
@hash.transform_keys!({ a: :A, b: :B, c: :C, d: :D }) @hash.transform_keys!({ a: :A, b: :B, c: :C, d: :D })
@hash.should == { A: 1, B: 2, C: 3, D: 4 } @hash.should == { A: 1, B: 2, C: 3, D: 4 }
end end
end
describe "on frozen instance" do describe "on frozen instance" do
before :each do before :each do
@ -132,11 +128,9 @@ describe "Hash#transform_keys!" do
@hash.should == @initial_pairs @hash.should == @initial_pairs
end end
ruby_version_is "3.0" do
it "raises a FrozenError on hash argument" do it "raises a FrozenError on hash argument" do
->{ @hash.transform_keys!({ a: :A, b: :B, c: :C }) }.should raise_error(FrozenError) ->{ @hash.transform_keys!({ a: :A, b: :B, c: :C }) }.should raise_error(FrozenError)
end end
end
context "when no block is given" do context "when no block is given" do
it "does not raise an exception" do it "does not raise an exception" do

View File

@ -1,25 +1,5 @@
require_relative '../fixtures/classes' 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 describe :integer_arithmetic_coerce_not_rescue, shared: true do
it "does not rescue exception raised in other#coerce" do it "does not rescue exception raised in other#coerce" do
b = mock("numeric with failed #coerce") b = mock("numeric with failed #coerce")

View File

@ -7,15 +7,7 @@ describe "Integer#zero?" do
-1.should_not.zero? -1.should_not.zero?
end end
ruby_version_is "3.0" do
it "Integer#zero? overrides Numeric#zero?" do it "Integer#zero? overrides Numeric#zero?" do
42.method(:zero?).owner.should == Integer 42.method(:zero?).owner.should == Integer
end end
end
ruby_version_is ""..."3.0" do
it "Integer#zero? uses Numeric#zero?" do
42.method(:zero?).owner.should == Numeric
end
end
end end

View File

@ -1,47 +0,0 @@
# -*- encoding: utf-8 -*-
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
ruby_version_is ''...'3.0' do
describe "IO#bytes" do
before :each do
@io = IOSpecs.io_fixture "lines.txt"
@verbose, $VERBOSE = $VERBOSE, nil
end
after :each do
$VERBOSE = @verbose
@io.close unless @io.closed?
end
it "returns an enumerator of the next bytes from the stream" do
enum = @io.bytes
enum.should be_an_instance_of(Enumerator)
@io.readline.should == "Voici la ligne une.\n"
enum.first(5).should == [81, 117, 105, 32, 195]
end
it "yields each byte" do
count = 0
ScratchPad.record []
@io.each_byte do |byte|
ScratchPad << byte
break if 4 < count += 1
end
ScratchPad.recorded.should == [86, 111, 105, 99, 105]
end
it "raises an IOError on closed stream" do
enum = IOSpecs.closed_io.bytes
-> { enum.first }.should raise_error(IOError)
end
it "raises an IOError on an enumerator for a stream that has been closed" do
enum = @io.bytes
enum.first.should == 86
@io.close
-> { enum.first }.should raise_error(IOError)
end
end
end

View File

@ -1,30 +0,0 @@
# -*- encoding: utf-8 -*-
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
require_relative 'shared/chars'
ruby_version_is ''...'3.0' do
describe "IO#chars" do
before :each do
@verbose, $VERBOSE = $VERBOSE, nil
end
after :each do
$VERBOSE = @verbose
end
it_behaves_like :io_chars, :chars
end
describe "IO#chars" do
before :each do
@verbose, $VERBOSE = $VERBOSE, nil
end
after :each do
$VERBOSE = @verbose
end
it_behaves_like :io_chars_empty, :chars
end
end

View File

@ -1,38 +0,0 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
require_relative 'shared/codepoints'
ruby_version_is ''...'3.0' do
# See redmine #1667
describe "IO#codepoints" do
before :each do
@verbose, $VERBOSE = $VERBOSE, nil
end
after :each do
$VERBOSE = @verbose
end
it_behaves_like :io_codepoints, :codepoints
end
describe "IO#codepoints" do
before :each do
@io = IOSpecs.io_fixture "lines.txt"
@verbose, $VERBOSE = $VERBOSE, nil
end
after :each do
$VERBOSE = @verbose
@io.close unless @io.closed?
end
it "calls the given block" do
r = []
@io.codepoints { |c| r << c }
r[24].should == 232
r.last.should == 10
end
end
end

View File

@ -149,7 +149,6 @@ describe "IO#gets" do
@io.gets(chomp: true).should == IOSpecs.lines_without_newline_characters[0] @io.gets(chomp: true).should == IOSpecs.lines_without_newline_characters[0]
end end
ruby_version_is "3.0" do
it "raises exception when options passed as Hash" do it "raises exception when options passed as Hash" do
-> { @io.gets({ chomp: true }) }.should raise_error(TypeError) -> { @io.gets({ chomp: true }) }.should raise_error(TypeError)
@ -158,7 +157,6 @@ describe "IO#gets" do
}.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)")
end end
end end
end
end end
describe "IO#gets" do describe "IO#gets" do

View File

@ -27,7 +27,6 @@ describe "IO#initialize" do
@io.fileno.should == fd @io.fileno.should == fd
end end
ruby_version_is "3.0" do
it "accepts options as keyword arguments" do it "accepts options as keyword arguments" do
fd = new_fd @name, "w:utf-8" fd = new_fd @name, "w:utf-8"
@ -38,7 +37,6 @@ describe "IO#initialize" do
@io.send(:initialize, fd, "w", {flags: File::CREAT}) @io.send(:initialize, fd, "w", {flags: File::CREAT})
}.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 1..2)") }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 1..2)")
end end
end
it "raises a TypeError when passed an IO" do it "raises a TypeError when passed an IO" do
-> { @io.send :initialize, STDOUT, 'w' }.should raise_error(TypeError) -> { @io.send :initialize, STDOUT, 'w' }.should raise_error(TypeError)

View File

@ -1,46 +0,0 @@
# -*- encoding: utf-8 -*-
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
ruby_version_is ''...'3.0' do
describe "IO#lines" do
before :each do
@io = IOSpecs.io_fixture "lines.txt"
@verbose, $VERBOSE = $VERBOSE, nil
end
after :each do
$VERBOSE = @verbose
@io.close if @io
end
it "returns an Enumerator" do
@io.lines.should be_an_instance_of(Enumerator)
end
describe "when no block is given" do
it "returns an Enumerator" do
@io.lines.should be_an_instance_of(Enumerator)
end
describe "returned Enumerator" do
describe "size" do
it "should return nil" do
@io.lines.size.should == nil
end
end
end
end
it "returns a line when accessed" do
enum = @io.lines
enum.first.should == IOSpecs.lines[0]
end
it "yields each line to the passed block" do
ScratchPad.record []
@io.lines { |s| ScratchPad << s }
ScratchPad.recorded.should == IOSpecs.lines
end
end
end

View File

@ -12,27 +12,6 @@ platform_is_not :windows do
end end
end end
ruby_version_is ""..."3.0" do
it "returns false for pipe by default" do
r, w = IO.pipe
begin
r.nonblock?.should == false
w.nonblock?.should == false
ensure
r.close
w.close
end
end
it "returns false for socket by default" do
require 'socket'
TCPServer.open(0) do |socket|
socket.nonblock?.should == false
end
end
end
ruby_version_is "3.0" do
it "returns true for pipe by default" do it "returns true for pipe by default" do
r, w = IO.pipe r, w = IO.pipe
begin begin
@ -51,7 +30,6 @@ platform_is_not :windows do
end end
end end
end end
end
describe "IO#nonblock=" do describe "IO#nonblock=" do
before :all do before :all do

View File

@ -23,7 +23,6 @@ describe "IO.read" do
IO.read(p) IO.read(p)
end end
ruby_version_is "3.0" do
# https://bugs.ruby-lang.org/issues/19354 # https://bugs.ruby-lang.org/issues/19354
it "accepts options as keyword arguments" do it "accepts options as keyword arguments" do
IO.read(@fname, 3, 0, mode: "r+").should == @contents[0, 3] IO.read(@fname, 3, 0, mode: "r+").should == @contents[0, 3]
@ -32,7 +31,6 @@ describe "IO.read" do
IO.read(@fname, 3, 0, {mode: "r+"}) IO.read(@fname, 3, 0, {mode: "r+"})
}.should raise_error(ArgumentError, /wrong number of arguments/) }.should raise_error(ArgumentError, /wrong number of arguments/)
end end
end
it "accepts an empty options Hash" do it "accepts an empty options Hash" do
IO.read(@fname, **{}).should == @contents IO.read(@fname, **{}).should == @contents

View File

@ -73,7 +73,6 @@ describe "IO#readline" do
@io.readline(chomp: true).should == IOSpecs.lines_without_newline_characters[0] @io.readline(chomp: true).should == IOSpecs.lines_without_newline_characters[0]
end end
ruby_version_is "3.0" do
it "raises exception when options passed as Hash" do it "raises exception when options passed as Hash" do
-> { @io.readline({ chomp: true }) }.should raise_error(TypeError) -> { @io.readline({ chomp: true }) }.should raise_error(TypeError)
@ -82,5 +81,4 @@ describe "IO#readline" do
}.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)")
end end
end end
end
end end

View File

@ -117,7 +117,6 @@ describe "IO#readlines" do
@io.readlines(chomp: true).should == IOSpecs.lines_without_newline_characters @io.readlines(chomp: true).should == IOSpecs.lines_without_newline_characters
end end
ruby_version_is "3.0" do
it "raises exception when options passed as Hash" do it "raises exception when options passed as Hash" do
-> { @io.readlines({ chomp: true }) }.should raise_error(TypeError) -> { @io.readlines({ chomp: true }) }.should raise_error(TypeError)
@ -126,7 +125,6 @@ describe "IO#readlines" do
}.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)")
end end
end end
end
describe "when passed arbitrary keyword argument" do describe "when passed arbitrary keyword argument" do
it "tolerates it" do it "tolerates it" do

View File

@ -21,7 +21,6 @@ describe :io_binwrite, shared: true do
IO.send(@method, @filename, "abcde").should == 5 IO.send(@method, @filename, "abcde").should == 5
end end
ruby_version_is "3.0" do
it "accepts options as a keyword argument" do it "accepts options as a keyword argument" do
IO.send(@method, @filename, "hi", 0, flags: File::CREAT).should == 2 IO.send(@method, @filename, "hi", 0, flags: File::CREAT).should == 2
@ -29,7 +28,6 @@ describe :io_binwrite, shared: true do
IO.send(@method, @filename, "hi", 0, {flags: File::CREAT}) IO.send(@method, @filename, "hi", 0, {flags: File::CREAT})
}.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 2..3)") }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 2..3)")
end end
end
it "creates a file if missing" do it "creates a file if missing" do
fn = @filename + "xxx" fn = @filename + "xxx"

View File

@ -180,7 +180,6 @@ describe :io_each, shared: true do
ScratchPad.recorded.should == IOSpecs.lines_without_newline_characters ScratchPad.recorded.should == IOSpecs.lines_without_newline_characters
end end
ruby_version_is "3.0" do
it "raises exception when options passed as Hash" do it "raises exception when options passed as Hash" do
-> { -> {
@io.send(@method, { chomp: true }) { |s| } @io.send(@method, { chomp: true }) { |s| }
@ -191,7 +190,6 @@ describe :io_each, shared: true do
}.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)")
end end
end end
end
describe "when passed chomp and a separator" do describe "when passed chomp and a separator" do
it "yields each line without separator to the passed block" do it "yields each line without separator to the passed block" do

View File

@ -64,7 +64,6 @@ describe :io_new, shared: true do
@io.should be_an_instance_of(IO) @io.should be_an_instance_of(IO)
end end
ruby_version_is "3.0" do
it "accepts options as keyword arguments" do it "accepts options as keyword arguments" do
@io = IO.send(@method, @fd, "w", flags: File::CREAT) @io = IO.send(@method, @fd, "w", flags: File::CREAT)
@io.write("foo").should == 3 @io.write("foo").should == 3
@ -73,7 +72,6 @@ describe :io_new, shared: true do
IO.send(@method, @fd, "w", {flags: File::CREAT}) IO.send(@method, @fd, "w", {flags: File::CREAT})
}.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 1..2)") }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 1..2)")
end end
end
it "accepts a :mode option" do it "accepts a :mode option" do
@io = IO.send(@method, @fd, mode: "w") @io = IO.send(@method, @fd, mode: "w")
@ -210,22 +208,11 @@ describe :io_new, shared: true do
@io.internal_encoding.to_s.should == 'IBM866' @io.internal_encoding.to_s.should == 'IBM866'
end end
ruby_version_is ''...'3.0' do
it "accepts nil options" do
@io = suppress_keyword_warning do
IO.send(@method, @fd, 'w', nil)
end
@io.write("foo").should == 3
end
end
ruby_version_is '3.0' do
it "raises ArgumentError for nil options" do it "raises ArgumentError for nil options" do
-> { -> {
IO.send(@method, @fd, 'w', nil) IO.send(@method, @fd, 'w', nil)
}.should raise_error(ArgumentError) }.should raise_error(ArgumentError)
end end
end
it "coerces mode with #to_str" do it "coerces mode with #to_str" do
mode = mock("mode") mode = mock("mode")
@ -395,21 +382,9 @@ describe :io_new_errors, shared: true do
}.should raise_error(ArgumentError) }.should raise_error(ArgumentError)
end end
ruby_version_is ''...'3.0' do
it "raises TypeError if passed a hash for mode and nil for options" do
-> {
suppress_keyword_warning do
@io = IO.send(@method, @fd, {mode: 'w'}, nil)
end
}.should raise_error(TypeError)
end
end
ruby_version_is '3.0' do
it "raises ArgumentError if passed a hash for mode and nil for options" do it "raises ArgumentError if passed a hash for mode and nil for options" do
-> { -> {
@io = IO.send(@method, @fd, {mode: 'w'}, nil) @io = IO.send(@method, @fd, {mode: 'w'}, nil)
}.should raise_error(ArgumentError) }.should raise_error(ArgumentError)
end end
end
end end

View File

@ -105,14 +105,12 @@ describe :io_readlines_options_19, shared: true do
end end
describe "when the object is an options Hash" do describe "when the object is an options Hash" do
ruby_version_is "3.0" do
it "raises TypeError exception" do it "raises TypeError exception" do
-> { -> {
IO.send(@method, @name, { chomp: true }, &@object) IO.send(@method, @name, { chomp: true }, &@object)
}.should raise_error(TypeError) }.should raise_error(TypeError)
end end
end end
end
describe "when the object is neither Integer nor String" do describe "when the object is neither Integer nor String" do
it "raises TypeError exception" do it "raises TypeError exception" do
@ -179,7 +177,6 @@ describe :io_readlines_options_19, shared: true do
end end
describe "when the second object is an options Hash" do describe "when the second object is an options Hash" do
ruby_version_is "3.0" do
it "raises TypeError exception" do it "raises TypeError exception" do
-> { -> {
IO.send(@method, @name, "", { chomp: true }, &@object) IO.send(@method, @name, "", { chomp: true }, &@object)
@ -187,7 +184,6 @@ describe :io_readlines_options_19, shared: true do
end end
end end
end end
end
describe "when passed name, object, keyword arguments" do describe "when passed name, object, keyword arguments" do
describe "when the first object is an Integer" do describe "when the first object is an Integer" do

View File

@ -103,20 +103,10 @@ describe "IO#ungetc" do
-> { @io.sysread(1) }.should raise_error(IOError) -> { @io.sysread(1) }.should raise_error(IOError)
end end
ruby_version_is ""..."3.0" do
it "does not affect the stream and returns nil when passed nil" do
@io.getc.should == ?V
@io.ungetc(nil)
@io.getc.should == ?o
end
end
ruby_version_is "3.0" do
it "raises TypeError if passed nil" do it "raises TypeError if passed nil" do
@io.getc.should == ?V @io.getc.should == ?V
proc{@io.ungetc(nil)}.should raise_error(TypeError) proc{@io.ungetc(nil)}.should raise_error(TypeError)
end end
end
it "puts one or more characters back in the stream" do it "puts one or more characters back in the stream" do
@io.gets @io.gets

View File

@ -259,8 +259,7 @@ platform_is :windows do
end end
end end
ruby_version_is "3.0" do describe "IO#write on STDOUT" do
describe "IO#write on STDOUT" do
# https://bugs.ruby-lang.org/issues/14413 # https://bugs.ruby-lang.org/issues/14413
platform_is_not :windows do platform_is_not :windows do
it "raises SignalException SIGPIPE if the stream is closed instead of Errno::EPIPE like other IOs" do it "raises SignalException SIGPIPE if the stream is closed instead of Errno::EPIPE like other IOs" do
@ -280,5 +279,4 @@ ruby_version_is "3.0" do
end end
end end
end end
end
end end

View File

@ -145,7 +145,7 @@ describe :kernel_integer, shared: true do
end end
end end
describe "Integer() given a String", shared: true do describe :kernel_integer_string, shared: true do
it "raises an ArgumentError if the String is a null byte" do it "raises an ArgumentError if the String is a null byte" do
-> { Integer("\0") }.should raise_error(ArgumentError) -> { Integer("\0") }.should raise_error(ArgumentError)
end end
@ -348,7 +348,7 @@ describe "Integer() given a String", shared: true do
end end
end end
describe "Integer() given a String and base", shared: true do describe :kernel_integer_string_base, shared: true do
it "raises an ArgumentError if the String is a null byte" do it "raises an ArgumentError if the String is a null byte" do
-> { Integer("\0", 2) }.should raise_error(ArgumentError) -> { Integer("\0", 2) }.should raise_error(ArgumentError)
end end
@ -784,9 +784,9 @@ describe "Kernel.Integer" do
# TODO: fix these specs # TODO: fix these specs
it_behaves_like :kernel_integer, :Integer, Kernel it_behaves_like :kernel_integer, :Integer, Kernel
it_behaves_like "Integer() given a String", :Integer it_behaves_like :kernel_integer_string, :Integer
it_behaves_like "Integer() given a String and base", :Integer it_behaves_like :kernel_integer_string_base, :Integer
it "is a public method" do it "is a public method" do
Kernel.Integer(10).should == 10 Kernel.Integer(10).should == 10
@ -798,9 +798,9 @@ describe "Kernel#Integer" do
# TODO: fix these specs # TODO: fix these specs
it_behaves_like :kernel_integer, :Integer, Object.new it_behaves_like :kernel_integer, :Integer, Object.new
it_behaves_like "Integer() given a String", :Integer it_behaves_like :kernel_integer_string, :Integer
it_behaves_like "Integer() given a String and base", :Integer it_behaves_like :kernel_integer_string_base, :Integer
it "is a private method" do it "is a private method" do
Kernel.should have_private_instance_method(:Integer) Kernel.should have_private_instance_method(:Integer)

View File

@ -19,19 +19,9 @@ describe "Kernel#__dir__" do
end end
end end
ruby_version_is ""..."3.0" do
context "when used in eval with top level binding" do
it "returns the real name of the directory containing the currently-executing file" do
eval("__dir__", binding).should == File.realpath(File.dirname(__FILE__))
end
end
end
ruby_version_is "3.0" do
context "when used in eval with top level binding" do context "when used in eval with top level binding" do
it "returns nil" do it "returns nil" do
eval("__dir__", binding).should == nil eval("__dir__", binding).should == nil
end end
end end
end
end end

View File

@ -45,13 +45,6 @@ describe "Kernel#clone" do
end end
describe "with freeze: nil" do describe "with freeze: nil" do
ruby_version_is ""..."3.0" do
it "raises ArgumentError" do
-> { @obj.clone(freeze: nil) }.should raise_error(ArgumentError, /unexpected value for freeze: NilClass/)
end
end
ruby_version_is "3.0" do
it "copies frozen state from the original, like #clone without arguments" do it "copies frozen state from the original, like #clone without arguments" do
o2 = @obj.clone(freeze: nil) o2 = @obj.clone(freeze: nil)
o2.should_not.frozen? o2.should_not.frozen?
@ -66,7 +59,6 @@ describe "Kernel#clone" do
o.frozen?.should be_true o.frozen?.should be_true
end end
end end
end
describe "with freeze: true" do describe "with freeze: true" do
it 'makes a frozen copy if the original is frozen' do it 'makes a frozen copy if the original is frozen' do
@ -74,19 +66,6 @@ describe "Kernel#clone" do
@obj.clone(freeze: true).should.frozen? @obj.clone(freeze: true).should.frozen?
end end
ruby_version_is ''...'3.0' do
it 'does not freeze the copy even if the original is not frozen' do
@obj.clone(freeze: true).should_not.frozen?
end
it "calls #initialize_clone with no kwargs" do
obj = KernelSpecs::CloneFreeze.new
obj.clone(freeze: true)
ScratchPad.recorded.should == [obj, {}]
end
end
ruby_version_is '3.0' do
it 'freezes the copy even if the original was not frozen' do it 'freezes the copy even if the original was not frozen' do
@obj.clone(freeze: true).should.frozen? @obj.clone(freeze: true).should.frozen?
end end
@ -102,7 +81,6 @@ describe "Kernel#clone" do
-> { obj.clone(freeze: true) }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)') -> { obj.clone(freeze: true) }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)')
end end
end end
end
describe "with freeze: false" do describe "with freeze: false" do
it 'does not freeze the copy if the original is frozen' do it 'does not freeze the copy if the original is frozen' do
@ -114,15 +92,6 @@ describe "Kernel#clone" do
@obj.clone(freeze: false).should_not.frozen? @obj.clone(freeze: false).should_not.frozen?
end end
ruby_version_is ''...'3.0' do
it "calls #initialize_clone with no kwargs" do
obj = KernelSpecs::CloneFreeze.new
obj.clone(freeze: false)
ScratchPad.recorded.should == [obj, {}]
end
end
ruby_version_is '3.0' do
it "calls #initialize_clone with kwargs freeze: false" do it "calls #initialize_clone with kwargs freeze: false" do
obj = KernelSpecs::CloneFreeze.new obj = KernelSpecs::CloneFreeze.new
obj.clone(freeze: false) obj.clone(freeze: false)
@ -134,7 +103,6 @@ describe "Kernel#clone" do
-> { obj.clone(freeze: false) }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)') -> { obj.clone(freeze: false) }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)')
end end
end end
end
describe "with freeze: anything else" do describe "with freeze: anything else" do
it 'raises ArgumentError when passed not true/false/nil' do it 'raises ArgumentError when passed not true/false/nil' do

View File

@ -159,24 +159,6 @@ describe "Kernel#eval" do
end end
end end
ruby_version_is ""..."3.0" do
it "uses the filename of the binding if none is provided" do
eval("__FILE__").should == "(eval)"
suppress_warning {eval("__FILE__", binding)}.should == __FILE__
eval("__FILE__", binding, "success").should == "success"
suppress_warning {eval("eval '__FILE__', binding")}.should == "(eval)"
suppress_warning {eval("eval '__FILE__', binding", binding)}.should == __FILE__
suppress_warning {eval("eval '__FILE__', binding", binding, 'success')}.should == 'success'
end
it 'uses the given binding file and line for __FILE__ and __LINE__' do
suppress_warning {
eval("[__FILE__, __LINE__]", binding).should == [__FILE__, __LINE__]
}
end
end
ruby_version_is "3.0" do
it "uses (eval) filename if none is provided" do it "uses (eval) filename if none is provided" do
eval("__FILE__").should == "(eval)" eval("__FILE__").should == "(eval)"
eval("__FILE__", binding).should == "(eval)" eval("__FILE__", binding).should == "(eval)"
@ -190,7 +172,6 @@ describe "Kernel#eval" do
it 'uses (eval) for __FILE__ and 1 for __LINE__ with a binding argument' do it 'uses (eval) for __FILE__ and 1 for __LINE__ with a binding argument' do
eval("[__FILE__, __LINE__]", binding).should == ["(eval)", 1] eval("[__FILE__, __LINE__]", binding).should == ["(eval)", 1]
end end
end
# Found via Rubinius bug github:#149 # Found via Rubinius bug github:#149
it "does not alter the value of __FILE__ in the binding" do it "does not alter the value of __FILE__ in the binding" do

View File

@ -18,11 +18,9 @@ describe "Kernel#initialize_clone" do
a.send(:initialize_clone, b) a.send(:initialize_clone, b)
end end
ruby_version_is "3.0" do
it "accepts a :freeze keyword argument for obj.clone(freeze: value)" do it "accepts a :freeze keyword argument for obj.clone(freeze: value)" do
a = Object.new a = Object.new
b = Object.new b = Object.new
a.send(:initialize_clone, b, freeze: true).should == a a.send(:initialize_clone, b, freeze: true).should == a
end end
end
end end

View File

@ -1,14 +0,0 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
ruby_version_is ""..."3.0" do
describe "Kernel#iterator?" do
it "is a private method" do
Kernel.should have_private_instance_method(:iterator?)
end
end
describe "Kernel.iterator?" do
it "needs to be reviewed for spec completeness"
end
end

View File

@ -136,7 +136,6 @@ describe "Kernel.lambda" do
klass.new.ret.should == 1 klass.new.ret.should == 1
end end
ruby_version_is "3.0" do
context "when called without a literal block" do context "when called without a literal block" do
it "warns when proc isn't a lambda" do it "warns when proc isn't a lambda" do
-> { lambda(&proc{}) }.should complain("#{__FILE__}:#{__LINE__}: warning: lambda without a literal block is deprecated; use the proc without lambda instead\n") -> { lambda(&proc{}) }.should complain("#{__FILE__}:#{__LINE__}: warning: lambda without a literal block is deprecated; use the proc without lambda instead\n")
@ -146,5 +145,4 @@ describe "Kernel.lambda" do
-> { lambda(&lambda{}) }.should_not complain(verbose: true) -> { lambda(&lambda{}) }.should_not complain(verbose: true)
end end
end end
end
end end

View File

@ -72,7 +72,6 @@ describe "Kernel#open" do
-> { open }.should raise_error(ArgumentError) -> { open }.should raise_error(ArgumentError)
end end
ruby_version_is "3.0" do
it "accepts options as keyword arguments" do it "accepts options as keyword arguments" do
@file = open(@name, "r", 0666, flags: File::CREAT) @file = open(@name, "r", 0666, flags: File::CREAT)
@file.should be_kind_of(File) @file.should be_kind_of(File)
@ -81,7 +80,6 @@ describe "Kernel#open" do
open(@name, "r", 0666, {flags: File::CREAT}) open(@name, "r", 0666, {flags: File::CREAT})
}.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)")
end end
end
describe "when given an object that responds to to_open" do describe "when given an object that responds to to_open" do
before :each do before :each do
@ -158,19 +156,6 @@ describe "Kernel#open" do
open(@name, nil, nil) { |f| f.gets }.should == @content open(@name, nil, nil) { |f| f.gets }.should == @content
end end
ruby_version_is ""..."3.0" do
it "works correctly when redefined by open-uri" do
code = <<~RUBY
require 'open-uri'
obj = Object.new
def obj.to_open; self; end
p open(obj) == obj
RUBY
ruby_exe(code, args: "2>&1").should == "true\n"
end
end
ruby_version_is "3.0" do
it "is not redefined by open-uri" do it "is not redefined by open-uri" do
code = <<~RUBY code = <<~RUBY
before = Kernel.instance_method(:open) before = Kernel.instance_method(:open)
@ -180,7 +165,6 @@ describe "Kernel#open" do
RUBY RUBY
ruby_exe(code, args: "2>&1").should == "true\n" ruby_exe(code, args: "2>&1").should == "true\n"
end end
end
end end
describe "Kernel.open" do describe "Kernel.open" do

View File

@ -40,19 +40,9 @@ describe "Kernel#proc" do
proc proc
end end
ruby_version_is ""..."3.0" do
it "can be created when called with no block" do
-> {
some_method { "hello" }
}.should complain(/Capturing the given block using Kernel#proc is deprecated/)
end
end
ruby_version_is "3.0" do
it "raises an ArgumentError when passed no block" do it "raises an ArgumentError when passed no block" do
-> { -> {
some_method { "hello" } some_method { "hello" }
}.should raise_error(ArgumentError, 'tried to create Proc object without a block') }.should raise_error(ArgumentError, 'tried to create Proc object without a block')
end end
end
end end

View File

@ -262,7 +262,6 @@ describe :kernel_require, shared: true do
ScratchPad.recorded.should == [:loaded] ScratchPad.recorded.should == [:loaded]
end end
ruby_bug "#16926", ""..."3.0" do
it "does not load a feature twice when $LOAD_PATH has been modified" do it "does not load a feature twice when $LOAD_PATH has been modified" do
$LOAD_PATH.replace [CODE_LOADING_DIR] $LOAD_PATH.replace [CODE_LOADING_DIR]
@object.require("load_fixture").should be_true @object.require("load_fixture").should be_true
@ -270,7 +269,6 @@ describe :kernel_require, shared: true do
@object.require("load_fixture").should be_false @object.require("load_fixture").should be_false
end end
end end
end
describe "(file extensions)" do describe "(file extensions)" do
it "loads a .rb extensioned file when passed a non-extensioned path" do it "loads a .rb extensioned file when passed a non-extensioned path" do
@ -566,7 +564,6 @@ describe :kernel_require, shared: true do
-> { @object.require("unicode_normalize") }.should raise_error(LoadError) -> { @object.require("unicode_normalize") }.should raise_error(LoadError)
end end
ruby_version_is "3.0" do
it "does not load a file earlier on the $LOAD_PATH when other similar features were already loaded" do it "does not load a file earlier on the $LOAD_PATH when other similar features were already loaded" do
Dir.chdir CODE_LOADING_DIR do Dir.chdir CODE_LOADING_DIR do
@object.send(@method, "../code/load_fixture").should be_true @object.send(@method, "../code/load_fixture").should be_true
@ -584,7 +581,6 @@ describe :kernel_require, shared: true do
ScratchPad.recorded.should == [:loaded, :loaded] ScratchPad.recorded.should == [:loaded, :loaded]
end end
end end
end
describe "(shell expansion)" do describe "(shell expansion)" do
before :each do before :each do

View File

@ -1,3 +1,4 @@
# truffleruby_primitives: true
require_relative '../../spec_helper' require_relative '../../spec_helper'
describe "Kernel#singleton_class" do describe "Kernel#singleton_class" do
@ -42,4 +43,32 @@ describe "Kernel#singleton_class" do
obj.freeze obj.freeze
obj.singleton_class.frozen?.should be_true obj.singleton_class.frozen?.should be_true
end end
context "for an IO object with a replaced singleton class" do
it "looks up singleton methods from the fresh singleton class after an object instance got a new one" do
proxy = -> io { io.foo }
if RUBY_ENGINE == 'truffleruby'
# We need an inline cache with only this object seen, the best way to do that is to use a Primitive
sclass = -> io { Primitive.singleton_class(io) }
else
sclass = -> io { io.singleton_class }
end
io = File.new(__FILE__)
io.define_singleton_method(:foo) { "old" }
sclass1 = sclass.call(io)
proxy.call(io).should == "old"
# IO#reopen is the only method which can replace an object's singleton class
io2 = File.new(__FILE__)
io.reopen(io2)
io.define_singleton_method(:foo) { "new" }
sclass2 = sclass.call(io)
sclass2.should_not.equal?(sclass1)
proxy.call(io).should == "new"
ensure
io2.close
io.close
end
end
end end

View File

@ -4,10 +4,12 @@ require_relative 'fixtures/classes'
describe "Kernel#taint" do describe "Kernel#taint" do
ruby_version_is ""..."3.2" do ruby_version_is ""..."3.2" do
it "is a no-op" do it "is a no-op" do
suppress_warning do
o = Object.new o = Object.new
o.taint o.taint
o.should_not.tainted? o.should_not.tainted?
end end
end
it "warns in verbose mode" do it "warns in verbose mode" do
-> { -> {

View File

@ -4,12 +4,14 @@ require_relative 'fixtures/classes'
describe "Kernel#tainted?" do describe "Kernel#tainted?" do
ruby_version_is ""..."3.2" do ruby_version_is ""..."3.2" do
it "is a no-op" do it "is a no-op" do
suppress_warning do
o = mock('o') o = mock('o')
p = mock('p') p = mock('p')
p.taint p.taint
o.should_not.tainted? o.should_not.tainted?
p.should_not.tainted? p.should_not.tainted?
end end
end
it "warns in verbose mode" do it "warns in verbose mode" do
-> { -> {

View File

@ -4,11 +4,13 @@ require_relative 'fixtures/classes'
describe "Kernel#trust" do describe "Kernel#trust" do
ruby_version_is ""..."3.2" do ruby_version_is ""..."3.2" do
it "is a no-op" do it "is a no-op" do
suppress_warning do
o = Object.new.untrust o = Object.new.untrust
o.should_not.untrusted? o.should_not.untrusted?
o.trust o.trust
o.should_not.untrusted? o.should_not.untrusted?
end end
end
it "warns in verbose mode" do it "warns in verbose mode" do
-> { -> {

View File

@ -4,11 +4,13 @@ require_relative 'fixtures/classes'
describe "Kernel#untaint" do describe "Kernel#untaint" do
ruby_version_is ""..."3.2" do ruby_version_is ""..."3.2" do
it "is a no-op" do it "is a no-op" do
suppress_warning do
o = Object.new.taint o = Object.new.taint
o.should_not.tainted? o.should_not.tainted?
o.untaint o.untaint
o.should_not.tainted? o.should_not.tainted?
end end
end
it "warns in verbose mode" do it "warns in verbose mode" do
-> { -> {

View File

@ -4,10 +4,12 @@ require_relative 'fixtures/classes'
describe "Kernel#untrust" do describe "Kernel#untrust" do
ruby_version_is ""..."3.2" do ruby_version_is ""..."3.2" do
it "is a no-op" do it "is a no-op" do
suppress_warning do
o = Object.new o = Object.new
o.untrust o.untrust
o.should_not.untrusted? o.should_not.untrusted?
end end
end
it "warns in verbose mode" do it "warns in verbose mode" do
-> { -> {

View File

@ -4,11 +4,13 @@ require_relative 'fixtures/classes'
describe "Kernel#untrusted?" do describe "Kernel#untrusted?" do
ruby_version_is ""..."3.2" do ruby_version_is ""..."3.2" do
it "is a no-op" do it "is a no-op" do
suppress_warning do
o = mock('o') o = mock('o')
o.should_not.untrusted? o.should_not.untrusted?
o.untrust o.untrust
o.should_not.untrusted? o.should_not.untrusted?
end end
end
it "warns in verbose mode" do it "warns in verbose mode" do
-> { -> {

View File

@ -128,7 +128,6 @@ describe "Kernel#warn" do
end end
end end
ruby_version_is "3.0" do
it "accepts :category keyword with a symbol" do it "accepts :category keyword with a symbol" do
-> { -> {
$VERBOSE = true $VERBOSE = true
@ -158,7 +157,6 @@ describe "Kernel#warn" do
warn("message", category: Object.new) warn("message", category: Object.new)
}.should raise_error(TypeError) }.should raise_error(TypeError)
end end
end
it "converts first arg using to_s" do it "converts first arg using to_s" do
w = KernelSpecs::WarnInNestedCall.new w = KernelSpecs::WarnInNestedCall.new
@ -212,7 +210,6 @@ describe "Kernel#warn" do
-> { warn('foo', **h) }.should complain("foo\n") -> { warn('foo', **h) }.should complain("foo\n")
end end
ruby_version_is '3.0' do
it "calls Warning.warn without keyword arguments if Warning.warn does not accept keyword arguments" do it "calls Warning.warn without keyword arguments if Warning.warn does not accept keyword arguments" do
verbose = $VERBOSE verbose = $VERBOSE
$VERBOSE = false $VERBOSE = false
@ -261,20 +258,6 @@ describe "Kernel#warn" do
$VERBOSE = verbose $VERBOSE = verbose
end end
end end
end
ruby_version_is ''...'3.0' do
it "calls Warning.warn with no keyword arguments" do
Warning.should_receive(:warn).with("Chunky bacon!\n")
verbose = $VERBOSE
$VERBOSE = false
begin
Kernel.warn("Chunky bacon!")
ensure
$VERBOSE = verbose
end
end
end
it "does not call Warning.warn if self is the Warning module" do it "does not call Warning.warn if self is the Warning module" do
# RubyGems redefines Kernel#warn so we need to use a subprocess and disable RubyGems here # RubyGems redefines Kernel#warn so we need to use a subprocess and disable RubyGems here

View File

@ -22,7 +22,6 @@ describe "main#private" do
end end
end end
ruby_version_is "3.0" do
context "when single argument is passed and is an array" do context "when single argument is passed and is an array" do
it "sets the visibility of the given methods to private" do it "sets the visibility of the given methods to private" do
eval "private [:main_public_method, :main_public_method2]", TOPLEVEL_BINDING eval "private [:main_public_method, :main_public_method2]", TOPLEVEL_BINDING
@ -30,7 +29,6 @@ describe "main#private" do
Object.should have_private_method(:main_public_method2) Object.should have_private_method(:main_public_method2)
end end
end end
end
ruby_version_is ''...'3.1' do ruby_version_is ''...'3.1' do
it "returns Object" do it "returns Object" do

View File

@ -22,7 +22,6 @@ describe "main#public" do
end end
end end
ruby_version_is "3.0" do
context "when single argument is passed and is an array" do context "when single argument is passed and is an array" do
it "sets the visibility of the given methods to public" do it "sets the visibility of the given methods to public" do
eval "public [:main_private_method, :main_private_method2]", TOPLEVEL_BINDING eval "public [:main_private_method, :main_private_method2]", TOPLEVEL_BINDING
@ -30,7 +29,6 @@ describe "main#public" do
Object.should_not have_private_method(:main_private_method2) Object.should_not have_private_method(:main_private_method2)
end end
end end
end
ruby_version_is ''...'3.1' do ruby_version_is ''...'3.1' do
it "returns Object" do it "returns Object" do

View File

@ -626,17 +626,6 @@ describe "Marshal.dump" do
load.should == (1...2) load.should == (1...2)
end end
ruby_version_is ""..."3.0" do
it "dumps a Range with extra instance variables" do
range = (1...3)
range.instance_variable_set :@foo, 42
dump = Marshal.dump(range)
load = Marshal.load(dump)
load.should == range
load.instance_variable_get(:@foo).should == 42
end
end
it "raises TypeError with an anonymous Range subclass" do it "raises TypeError with an anonymous Range subclass" do
-> { Marshal.dump(Class.new(Range).new(1, 2)) }.should raise_error(TypeError, /can't dump anonymous class/) -> { Marshal.dump(Class.new(Range).new(1, 2)) }.should raise_error(TypeError, /can't dump anonymous class/)
end end

View File

@ -623,6 +623,14 @@ describe :marshal_load, shared: true do
value.map(&:encoding).should == [Encoding::UTF_8, Encoding::UTF_8, Encoding::UTF_8] value.map(&:encoding).should == [Encoding::UTF_8, Encoding::UTF_8, Encoding::UTF_8]
value.should == [*expected, expected[0]] value.should == [*expected, expected[0]]
end end
it "raises ArgumentError when end of byte sequence reached before symbol characters end" do
Marshal.dump(:hello).should == "\x04\b:\nhello"
-> {
Marshal.send(@method, "\x04\b:\nhel")
}.should raise_error(ArgumentError, "marshal data too short")
end
end end
describe "for a String" do describe "for a String" do
@ -685,6 +693,14 @@ describe :marshal_load, shared: true do
result.encoding.should == Encoding::BINARY result.encoding.should == Encoding::BINARY
result.should == str result.should == str
end end
it "raises ArgumentError when end of byte sequence reached before string characters end" do
Marshal.dump("hello").should == "\x04\b\"\nhello"
-> {
Marshal.send(@method, "\x04\b\"\nhel")
}.should raise_error(ArgumentError, "marshal data too short")
end
end end
describe "for a Struct" do describe "for a Struct" do
@ -819,6 +835,14 @@ describe :marshal_load, shared: true do
Marshal.send(@method, "\x04\bo:\tFile\001\001:\001\005@path\"\x10/etc/passwd") Marshal.send(@method, "\x04\bo:\tFile\001\001:\001\005@path\"\x10/etc/passwd")
end.should raise_error(ArgumentError) end.should raise_error(ArgumentError)
end end
it "raises ArgumentError when end of byte sequence reached before class name end" do
Marshal.dump(Object.new).should == "\x04\bo:\vObject\x00"
-> {
Marshal.send(@method, "\x04\bo:\vObj")
}.should raise_error(ArgumentError, "marshal data too short")
end
end end
describe "for an object responding to #marshal_dump and #marshal_load" do describe "for an object responding to #marshal_dump and #marshal_load" do
@ -908,6 +932,14 @@ describe :marshal_load, shared: true do
regexp.encoding.should == Encoding::UTF_32LE regexp.encoding.should == Encoding::UTF_32LE
regexp.source.should == "a".encode("utf-32le") regexp.source.should == "a".encode("utf-32le")
end end
it "raises ArgumentError when end of byte sequence reached before source string end" do
Marshal.dump(/hello world/).should == "\x04\bI/\x10hello world\x00\x06:\x06EF"
-> {
Marshal.send(@method, "\x04\bI/\x10hel")
}.should raise_error(ArgumentError, "marshal data too short")
end
end end
describe "for a Float" do describe "for a Float" do
@ -929,6 +961,14 @@ describe :marshal_load, shared: true do
obj = 1.1867345e+22 obj = 1.1867345e+22
Marshal.send(@method, "\004\bf\0361.1867344999999999e+22\000\344@").should == obj Marshal.send(@method, "\004\bf\0361.1867344999999999e+22\000\344@").should == obj
end end
it "raises ArgumentError when end of byte sequence reached before float string representation end" do
Marshal.dump(1.3).should == "\x04\bf\b1.3"
-> {
Marshal.send(@method, "\004\bf\v1")
}.should raise_error(ArgumentError, "marshal data too short")
end
end end
describe "for an Integer" do describe "for an Integer" do
@ -1114,6 +1154,14 @@ describe :marshal_load, shared: true do
it "raises ArgumentError if given a nonexistent class" do it "raises ArgumentError if given a nonexistent class" do
-> { Marshal.send(@method, "\x04\bc\vStrung") }.should raise_error(ArgumentError) -> { Marshal.send(@method, "\x04\bc\vStrung") }.should raise_error(ArgumentError)
end end
it "raises ArgumentError when end of byte sequence reached before class name end" do
Marshal.dump(String).should == "\x04\bc\vString"
-> {
Marshal.send(@method, "\x04\bc\vStr")
}.should raise_error(ArgumentError, "marshal data too short")
end
end end
describe "for a Module" do describe "for a Module" do
@ -1128,6 +1176,14 @@ describe :marshal_load, shared: true do
it "loads an old module" do it "loads an old module" do
Marshal.send(@method, "\x04\bM\vKernel").should == Kernel Marshal.send(@method, "\x04\bM\vKernel").should == Kernel
end end
it "raises ArgumentError when end of byte sequence reached before module name end" do
Marshal.dump(Kernel).should == "\x04\bm\vKernel"
-> {
Marshal.send(@method, "\x04\bm\vKer")
}.should raise_error(ArgumentError, "marshal data too short")
end
end end
describe "for a wrapped C pointer" do describe "for a wrapped C pointer" do

View File

@ -48,12 +48,10 @@ describe "MatchData#[]" do
/(.)(.)(\d+)(\d)/.match("THX1138.")[nil..nil].should == %w|HX1138 H X 113 8| /(.)(.)(\d+)(\d)/.match("THX1138.")[nil..nil].should == %w|HX1138 H X 113 8|
end end
ruby_version_is "3.0" do
it "returns instances of String when given a String subclass" do it "returns instances of String when given a String subclass" do
str = MatchDataSpecs::MyString.new("THX1138.") str = MatchDataSpecs::MyString.new("THX1138.")
/(.)(.)(\d+)(\d)/.match(str)[0..-1].each { |m| m.should be_an_instance_of(String) } /(.)(.)(\d+)(\d)/.match(str)[0..-1].each { |m| m.should be_an_instance_of(String) }
end end
end
end end
describe "MatchData#[Symbol]" do describe "MatchData#[Symbol]" do

View File

@ -17,10 +17,8 @@ describe "MatchData#post_match" do
str.match(/c/).post_match.encoding.should equal(Encoding::ISO_8859_1) str.match(/c/).post_match.encoding.should equal(Encoding::ISO_8859_1)
end end
ruby_version_is "3.0" do
it "returns an instance of String when given a String subclass" do it "returns an instance of String when given a String subclass" do
str = MatchDataSpecs::MyString.new("THX1138: The Movie") str = MatchDataSpecs::MyString.new("THX1138: The Movie")
/(.)(.)(\d+)(\d)/.match(str).post_match.should be_an_instance_of(String) /(.)(.)(\d+)(\d)/.match(str).post_match.should be_an_instance_of(String)
end end
end
end end

View File

@ -17,10 +17,8 @@ describe "MatchData#pre_match" do
str.match(/a/).pre_match.encoding.should equal(Encoding::ISO_8859_1) str.match(/a/).pre_match.encoding.should equal(Encoding::ISO_8859_1)
end end
ruby_version_is "3.0" do
it "returns an instance of String when given a String subclass" do it "returns an instance of String when given a String subclass" do
str = MatchDataSpecs::MyString.new("THX1138: The Movie") str = MatchDataSpecs::MyString.new("THX1138: The Movie")
/(.)(.)(\d+)(\d)/.match(str).pre_match.should be_an_instance_of(String) /(.)(.)(\d+)(\d)/.match(str).pre_match.should be_an_instance_of(String)
end end
end
end end

View File

@ -6,10 +6,8 @@ describe :matchdata_captures, shared: true do
/(.)(.)(\d+)(\d)/.match("THX1138.").send(@method).should == ["H","X","113","8"] /(.)(.)(\d+)(\d)/.match("THX1138.").send(@method).should == ["H","X","113","8"]
end end
ruby_version_is "3.0" do
it "returns instances of String when given a String subclass" do it "returns instances of String when given a String subclass" do
str = MatchDataSpecs::MyString.new("THX1138: The Movie") str = MatchDataSpecs::MyString.new("THX1138: The Movie")
/(.)(.)(\d+)(\d)/.match(str).send(@method).each { |c| c.should be_an_instance_of(String) } /(.)(.)(\d+)(\d)/.match(str).send(@method).each { |c| c.should be_an_instance_of(String) }
end end
end
end end

View File

@ -6,10 +6,8 @@ describe "MatchData#to_a" do
/(.)(.)(\d+)(\d)/.match("THX1138.").to_a.should == ["HX1138", "H", "X", "113", "8"] /(.)(.)(\d+)(\d)/.match("THX1138.").to_a.should == ["HX1138", "H", "X", "113", "8"]
end end
ruby_version_is "3.0" do
it "returns instances of String when given a String subclass" do it "returns instances of String when given a String subclass" do
str = MatchDataSpecs::MyString.new("THX1138.") str = MatchDataSpecs::MyString.new("THX1138.")
/(.)(.)(\d+)(\d)/.match(str)[0..-1].to_a.each { |m| m.should be_an_instance_of(String) } /(.)(.)(\d+)(\d)/.match(str)[0..-1].to_a.each { |m| m.should be_an_instance_of(String) }
end end
end
end end

View File

@ -6,10 +6,8 @@ describe "MatchData#to_s" do
/(.)(.)(\d+)(\d)/.match("THX1138.").to_s.should == "HX1138" /(.)(.)(\d+)(\d)/.match("THX1138.").to_s.should == "HX1138"
end end
ruby_version_is "3.0" do
it "returns an instance of String when given a String subclass" do it "returns an instance of String when given a String subclass" do
str = MatchDataSpecs::MyString.new("THX1138.") str = MatchDataSpecs::MyString.new("THX1138.")
/(.)(.)(\d+)(\d)/.match(str).to_s.should be_an_instance_of(String) /(.)(.)(\d+)(\d)/.match(str).to_s.should be_an_instance_of(String)
end end
end
end end

View File

@ -38,8 +38,7 @@ describe "Method#<<" do
double = proc { |x| x + x } double = proc { |x| x + x }
(pow_2 << double).is_a?(Proc).should == true (pow_2 << double).is_a?(Proc).should == true
ruby_version_is(''...'3.0') { (pow_2 << double).should.lambda? } (pow_2 << double).should_not.lambda?
ruby_version_is('3.0') { (pow_2 << double).should_not.lambda? }
end end
it "may accept multiple arguments" do it "may accept multiple arguments" do

View File

@ -53,7 +53,6 @@ describe :method_to_s, shared: true do
MethodSpecs::A.new.method(:baz).send(@method).should.start_with? "#<Method: MethodSpecs::A#baz" MethodSpecs::A.new.method(:baz).send(@method).should.start_with? "#<Method: MethodSpecs::A#baz"
end end
ruby_version_is '3.0' do
it "returns a String containing the Module containing the method if object has a singleton class but method is not defined in the singleton class" do it "returns a String containing the Module containing the method if object has a singleton class but method is not defined in the singleton class" do
obj = MethodSpecs::MySub.new obj = MethodSpecs::MySub.new
obj.singleton_class obj.singleton_class
@ -67,7 +66,6 @@ describe :method_to_s, shared: true do
@string = c.method(:bar).send(@method) @string = c.method(:bar).send(@method)
@string.should.start_with? "#<Method: #<Class:#{c.inspect}>(#{m.inspect})#bar" @string.should.start_with? "#<Method: #<Class:#{c.inspect}>(#{m.inspect})#bar"
end end
end
it "returns a String containing the singleton class if method is defined in the singleton class" do it "returns a String containing the singleton class if method is defined in the singleton class" do
obj = MethodSpecs::MySub.new obj = MethodSpecs::MySub.new
@ -77,9 +75,7 @@ describe :method_to_s, shared: true do
@string.should.start_with? "#<Method: #<MethodSpecs::MySub:0xXXXXXX>.bar" @string.should.start_with? "#<Method: #<MethodSpecs::MySub:0xXXXXXX>.bar"
end end
ruby_bug '#17428', ''...'3.0' do
it "shows the metaclass and the owner for a Module instance method retrieved from a class" do it "shows the metaclass and the owner for a Module instance method retrieved from a class" do
String.method(:include).inspect.should.start_with?("#<Method: #<Class:String>(Module)#include") String.method(:include).inspect.should.start_with?("#<Method: #<Class:String>(Module)#include")
end end
end
end end

View File

@ -92,19 +92,11 @@ describe "Module#alias_method" do
end end
describe "returned value" do describe "returned value" do
ruby_version_is ""..."3.0" do
it "returns self" do
@class.send(:alias_method, :checking_return_value, :public_one).should equal(@class)
end
end
ruby_version_is "3.0" do
it "returns symbol of the defined method name" do it "returns symbol of the defined method name" do
@class.send(:alias_method, :checking_return_value, :public_one).should equal(:checking_return_value) @class.send(:alias_method, :checking_return_value, :public_one).should equal(:checking_return_value)
@class.send(:alias_method, 'checking_return_value', :public_one).should equal(:checking_return_value) @class.send(:alias_method, 'checking_return_value', :public_one).should equal(:checking_return_value)
end end
end end
end
it "works in module" do it "works in module" do
ModuleSpecs::Allonym.new.publish.should == :report ModuleSpecs::Allonym.new.publish.should == :report

View File

@ -80,21 +80,11 @@ describe "Module#attr_accessor" do
Module.should have_public_instance_method(:attr_accessor, false) Module.should have_public_instance_method(:attr_accessor, false)
end end
ruby_version_is ""..."3.0" do
it "returns nil" do
Class.new do
(attr_accessor :foo, 'bar').should == nil
end
end
end
ruby_version_is "3.0" do
it "returns an array of defined method names as symbols" do it "returns an array of defined method names as symbols" do
Class.new do Class.new do
(attr_accessor :foo, 'bar').should == [:foo, :foo=, :bar, :bar=] (attr_accessor :foo, 'bar').should == [:foo, :foo=, :bar, :bar=]
end end
end end
end
describe "on immediates" do describe "on immediates" do
before :each do before :each do

View File

@ -62,19 +62,9 @@ describe "Module#attr_reader" do
Module.should have_public_instance_method(:attr_reader, false) Module.should have_public_instance_method(:attr_reader, false)
end end
ruby_version_is ""..."3.0" do
it "returns nil" do
Class.new do
(attr_reader :foo, 'bar').should == nil
end
end
end
ruby_version_is "3.0" do
it "returns an array of defined method names as symbols" do it "returns an array of defined method names as symbols" do
Class.new do Class.new do
(attr_reader :foo, 'bar').should == [:foo, :bar] (attr_reader :foo, 'bar').should == [:foo, :bar]
end end
end end
end
end end

View File

@ -146,17 +146,6 @@ describe "Module#attr" do
Module.should have_public_instance_method(:attr, false) Module.should have_public_instance_method(:attr, false)
end end
ruby_version_is ""..."3.0" do
it "returns nil" do
Class.new do
(attr :foo, 'bar').should == nil
(attr :baz, false).should == nil
(attr :qux, true).should == nil
end
end
end
ruby_version_is "3.0" do
it "returns an array of defined method names as symbols" do it "returns an array of defined method names as symbols" do
Class.new do Class.new do
(attr :foo, 'bar').should == [:foo, :bar] (attr :foo, 'bar').should == [:foo, :bar]
@ -164,5 +153,4 @@ describe "Module#attr" do
(attr :qux, true).should == [:qux, :qux=] (attr :qux, true).should == [:qux, :qux=]
end end
end end
end
end end

View File

@ -72,19 +72,9 @@ describe "Module#attr_writer" do
Module.should have_public_instance_method(:attr_writer, false) Module.should have_public_instance_method(:attr_writer, false)
end end
ruby_version_is ""..."3.0" do
it "returns nil" do
Class.new do
(attr_writer :foo, 'bar').should == nil
end
end
end
ruby_version_is "3.0" do
it "returns an array of defined method names as symbols" do it "returns an array of defined method names as symbols" do
Class.new do Class.new do
(attr_writer :foo, 'bar').should == [:foo=, :bar=] (attr_writer :foo, 'bar').should == [:foo=, :bar=]
end end
end end
end
end end

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