1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2022-04-25 14:53:54 +02:00
parent 6ae81d49b5
commit 45cf4f2187
277 changed files with 3844 additions and 7624 deletions

View file

@ -1,11 +1,12 @@
inherit_from: .rubocop_todo.yml inherit_from: .rubocop_todo.yml
AllCops: AllCops:
TargetRubyVersion: 2.6 TargetRubyVersion: 2.7
DisplayCopNames: true DisplayCopNames: true
Exclude: Exclude:
- command_line/fixtures/bad_syntax.rb - command_line/fixtures/bad_syntax.rb
DisabledByDefault: true DisabledByDefault: true
NewCops: disable
Layout/TrailingWhitespace: Layout/TrailingWhitespace:
Enabled: true Enabled: true
@ -56,12 +57,52 @@ Lint/UnusedMethodArgument:
Lint/UselessAssignment: Lint/UselessAssignment:
Enabled: false Enabled: false
Lint/UselessComparison: Lint/BinaryOperatorWithIdenticalOperands:
Enabled: false Enabled: false
Lint/EmptyConditionalBody:
Enabled: false # buggy
Lint/Void: Lint/Void:
Enabled: false Enabled: false
Lint/ConstantDefinitionInBlock:
Enabled: false
Lint/RaiseException:
Enabled: false
Lint/FloatComparison:
Enabled: false
Lint/DeprecatedClassMethods:
Enabled: false
Lint/UnreachableLoop:
Enabled: false
Lint/MissingSuper:
Enabled: false
Lint/UselessMethodDefinition:
Enabled: false
Lint/UselessTimes:
Enabled: false
Lint/MixedRegexpCaptureTypes:
Enabled: false
Lint/DuplicateElsifCondition:
Enabled: false
Lint/OutOfRangeRegexpRef:
Enabled: false
Lint/ElseLayout:
Exclude:
- 'language/if_spec.rb'
Lint/EmptyExpression: Lint/EmptyExpression:
Exclude: Exclude:
- 'language/**/*.rb' - 'language/**/*.rb'

View file

@ -180,7 +180,7 @@ First, file a bug at https://bugs.ruby-lang.org/.
It is better to use a `ruby_version_is` guard if there was a release with the fix. It is better to use a `ruby_version_is` guard if there was a release with the fix.
```ruby ```ruby
ruby_bug '#13669', ''...'2.7' do ruby_bug '#13669', ''...'3.2' do
it "works like this" do it "works like this" do
# Specify the expected behavior here, not the bug # Specify the expected behavior here, not the bug
end end

View file

@ -31,8 +31,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.6 and more recent Ruby versions. ruby/spec describes the behavior of Ruby 2.7 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.6.x, 2.7.x, 3.0.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 (2.7.x, 3.0.x, 3.1.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.3.8 - [Suite](https://github.com/ruby/spec/commit/dc733114d8ae66a3368ba3a98422c50147a76ba5) using [MSpec](https://github.com/ruby/mspec/commit/4599bc195fb109f2a482a01c32a7d659518369ea) * Ruby 2.3.8 - [Suite](https://github.com/ruby/spec/commit/dc733114d8ae66a3368ba3a98422c50147a76ba5) using [MSpec](https://github.com/ruby/mspec/commit/4599bc195fb109f2a482a01c32a7d659518369ea)
* Ruby 2.4.10 - [Suite](https://github.com/ruby/spec/commit/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)
### Running the specs ### Running the specs

View file

@ -19,8 +19,6 @@ describe "The -W command line option with 2" do
it_behaves_like :command_line_verbose, "-W2" it_behaves_like :command_line_verbose, "-W2"
end end
# Regarding the defaults, see core/warning/element_reference_spec.rb
ruby_version_is "2.7" do
describe "The -W command line option with :deprecated" do describe "The -W command line option with :deprecated" do
it "enables deprecation warnings" do it "enables deprecation warnings" do
ruby_exe('p Warning[:deprecated]', options: '-W:deprecated').should == "true\n" ruby_exe('p Warning[:deprecated]', options: '-W:deprecated').should == "true\n"
@ -44,4 +42,3 @@ ruby_version_is "2.7" do
ruby_exe('p Warning[:experimental]', options: '-w -W:no-experimental').should == "false\n" ruby_exe('p Warning[:experimental]', options: '-w -W:no-experimental').should == "false\n"
end end
end end
end

View file

@ -4,9 +4,7 @@ require_relative 'shared/verbose'
describe "The -w command line option" do describe "The -w command line option" do
it_behaves_like :command_line_verbose, "-w" it_behaves_like :command_line_verbose, "-w"
ruby_version_is "2.7" do
it "enables both deprecated and experimental warnings" do it "enables both deprecated and experimental warnings" do
ruby_exe('p Warning[:deprecated]; p Warning[:experimental]', options: '-w').should == "true\ntrue\n" ruby_exe('p Warning[:deprecated]; p Warning[:experimental]', options: '-w').should == "true\ntrue\n"
end end
end end
end

View file

@ -1 +1 @@
p "abc".object_id == "abc".object_id p "abc".equal?("abc")

View file

@ -59,7 +59,6 @@ describe "Processing RUBYOPT" do
ruby_exe("p $VERBOSE", escape: true).chomp.should == "true" ruby_exe("p $VERBOSE", escape: true).chomp.should == "true"
end end
ruby_version_is "2.7" do
it "suppresses deprecation warnings for '-W:no-deprecated'" do it "suppresses deprecation warnings for '-W:no-deprecated'" do
ENV["RUBYOPT"] = '-W:no-deprecated' ENV["RUBYOPT"] = '-W:no-deprecated'
result = ruby_exe('$; = ""', args: '2>&1') result = ruby_exe('$; = ""', args: '2>&1')
@ -77,7 +76,6 @@ describe "Processing RUBYOPT" do
result = ruby_exe('case ($; = ""); in a; end', args: '2>&1') result = ruby_exe('case ($; = ""); in a; end', args: '2>&1')
result.should == "" result.should == ""
end end
end
it "requires the file for '-r'" do it "requires the file for '-r'" do
f = fixture __FILE__, "rubyopt" f = fixture __FILE__, "rubyopt"

View file

@ -20,30 +20,10 @@ describe "Array#clear" do
a.size.should == 0 a.size.should == 0
end end
ruby_version_is ''...'2.7' do
it "keeps tainted status" do
a = [1]
a.taint
a.tainted?.should be_true
a.clear
a.tainted?.should be_true
end
end
it "does not accept any arguments" do it "does not accept any arguments" do
-> { [1].clear(true) }.should raise_error(ArgumentError) -> { [1].clear(true) }.should raise_error(ArgumentError)
end end
ruby_version_is ''...'2.7' do
it "keeps untrusted status" do
a = [1]
a.untrust
a.untrusted?.should be_true
a.clear
a.untrusted?.should be_true
end
end
it "raises a FrozenError on a frozen array" do it "raises a FrozenError on a frozen array" do
a = [1] a = [1]
a.freeze a.freeze

View file

@ -21,20 +21,6 @@ describe "Array#compact" do
it "does not return subclass instance for Array subclasses" do it "does not return subclass instance for Array subclasses" do
ArraySpecs::MyArray[1, 2, 3, nil].compact.should be_an_instance_of(Array) ArraySpecs::MyArray[1, 2, 3, nil].compact.should be_an_instance_of(Array)
end end
ruby_version_is ''...'2.7' do
it "does not keep tainted status even if all elements are removed" do
a = [nil, nil]
a.taint
a.compact.tainted?.should be_false
end
it "does not keep untrusted status even if all elements are removed" do
a = [nil, nil]
a.untrust
a.compact.untrusted?.should be_false
end
end
end end
describe "Array#compact!" do describe "Array#compact!" do
@ -59,22 +45,6 @@ describe "Array#compact!" do
[1, 2, false, 3].compact!.should == nil [1, 2, false, 3].compact!.should == nil
end end
ruby_version_is ''...'2.7' do
it "keeps tainted status even if all elements are removed" do
a = [nil, nil]
a.taint
a.compact!
a.tainted?.should be_true
end
it "keeps untrusted status even if all elements are removed" do
a = [nil, nil]
a.untrust
a.compact!
a.untrusted?.should be_true
end
end
it "raises a FrozenError on a frozen array" do it "raises a FrozenError on a frozen array" do
-> { ArraySpecs.frozen_array.compact! }.should raise_error(FrozenError) -> { ArraySpecs.frozen_array.compact! }.should raise_error(FrozenError)
end end

View file

@ -41,64 +41,6 @@ describe "Array#concat" do
-> { ArraySpecs.frozen_array.concat([]) }.should raise_error(FrozenError) -> { ArraySpecs.frozen_array.concat([]) }.should raise_error(FrozenError)
end end
ruby_version_is ''...'2.7' do
it "keeps tainted status" do
ary = [1, 2]
ary.taint
ary.concat([3])
ary.tainted?.should be_true
ary.concat([])
ary.tainted?.should be_true
end
it "is not infected by the other" do
ary = [1,2]
other = [3]; other.taint
ary.tainted?.should be_false
ary.concat(other)
ary.tainted?.should be_false
end
it "keeps the tainted status of elements" do
ary = [ Object.new, Object.new, Object.new ]
ary.each {|x| x.taint }
ary.concat([ Object.new ])
ary[0].tainted?.should be_true
ary[1].tainted?.should be_true
ary[2].tainted?.should be_true
ary[3].tainted?.should be_false
end
it "keeps untrusted status" do
ary = [1, 2]
ary.untrust
ary.concat([3])
ary.untrusted?.should be_true
ary.concat([])
ary.untrusted?.should be_true
end
it "is not infected untrustedness by the other" do
ary = [1,2]
other = [3]; other.untrust
ary.untrusted?.should be_false
ary.concat(other)
ary.untrusted?.should be_false
end
it "keeps the untrusted status of elements" do
ary = [ Object.new, Object.new, Object.new ]
ary.each {|x| x.untrust }
ary.concat([ Object.new ])
ary[0].untrusted?.should be_true
ary[1].untrusted?.should be_true
ary[2].untrusted?.should be_true
ary[3].untrusted?.should be_false
end
end
it "appends elements to an Array with enough capacity that has been shifted" do it "appends elements to an Array with enough capacity that has been shifted" do
ary = [1, 2, 3, 4, 5] ary = [1, 2, 3, 4, 5]
2.times { ary.shift } 2.times { ary.shift }

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
ruby_version_is "2.7" do
describe "Array#deconstruct" do describe "Array#deconstruct" do
it "returns self" do it "returns self" do
array = [1] array = [1]
@ -8,4 +7,3 @@ ruby_version_is "2.7" do
array.deconstruct.should equal array array.deconstruct.should equal array
end end
end end
end

View file

@ -38,26 +38,4 @@ describe "Array#delete_at" do
it "raises a FrozenError on a frozen array" do it "raises a FrozenError on a frozen array" do
-> { [1,2,3].freeze.delete_at(0) }.should raise_error(FrozenError) -> { [1,2,3].freeze.delete_at(0) }.should raise_error(FrozenError)
end end
ruby_version_is ''...'2.7' do
it "keeps tainted status" do
ary = [1, 2]
ary.taint
ary.tainted?.should be_true
ary.delete_at(0)
ary.tainted?.should be_true
ary.delete_at(0) # now empty
ary.tainted?.should be_true
end
it "keeps untrusted status" do
ary = [1, 2]
ary.untrust
ary.untrusted?.should be_true
ary.delete_at(0)
ary.untrusted?.should be_true
ary.delete_at(0) # now empty
ary.untrusted?.should be_true
end
end
end end

View file

@ -47,22 +47,6 @@ describe "Array#delete_if" do
-> { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(FrozenError) -> { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(FrozenError)
end end
ruby_version_is ''...'2.7' do
it "keeps tainted status" do
@a.taint
@a.tainted?.should be_true
@a.delete_if{ true }
@a.tainted?.should be_true
end
it "keeps untrusted status" do
@a.untrust
@a.untrusted?.should be_true
@a.delete_if{ true }
@a.untrusted?.should be_true
end
end
it_behaves_like :enumeratorized_with_origin_size, :delete_if, [1,2,3] it_behaves_like :enumeratorized_with_origin_size, :delete_if, [1,2,3]
it_behaves_like :delete_if, :delete_if it_behaves_like :delete_if, :delete_if
end end

View file

@ -43,26 +43,4 @@ describe "Array#delete" do
it "raises a FrozenError on a frozen array" do it "raises a FrozenError on a frozen array" do
-> { [1, 2, 3].freeze.delete(1) }.should raise_error(FrozenError) -> { [1, 2, 3].freeze.delete(1) }.should raise_error(FrozenError)
end end
ruby_version_is ''...'2.7' do
it "keeps tainted status" do
a = [1, 2]
a.taint
a.tainted?.should be_true
a.delete(2)
a.tainted?.should be_true
a.delete(1) # now empty
a.tainted?.should be_true
end
it "keeps untrusted status" do
a = [1, 2]
a.untrust
a.untrusted?.should be_true
a.delete(2)
a.untrusted?.should be_true
a.delete(1) # now empty
a.untrusted?.should be_true
end
end
end end

View file

@ -481,52 +481,50 @@ describe "Array#[]= with [m..]" do
end end
end end
ruby_version_is "2.7" do
describe "Array#[]= with [..n] and [...n]" do describe "Array#[]= with [..n] and [...n]" do
it "just sets the section defined by range to nil even if the rhs is nil" do it "just sets the section defined by range to nil even if the rhs is nil" do
a = [1, 2, 3, 4, 5] a = [1, 2, 3, 4, 5]
a[eval("(..2)")] = nil a[(..2)] = nil
a.should == [nil, 4, 5] a.should == [nil, 4, 5]
a[eval("(...2)")] = nil a[(...2)] = nil
a.should == [nil, 5] a.should == [nil, 5]
end end
it "just sets the section defined by range to nil if n < 0 and the rhs is nil" do it "just sets the section defined by range to nil if n < 0 and the rhs is nil" do
a = [1, 2, 3, 4, 5] a = [1, 2, 3, 4, 5]
a[eval("(..-3)")] = nil a[(..-3)] = nil
a.should == [nil, 4, 5] a.should == [nil, 4, 5]
a[eval("(...-1)")] = [nil, 5] a[(...-1)] = [nil, 5]
end end
it "replaces the section defined by range" do it "replaces the section defined by range" do
a = [6, 5, 4, 3, 2, 1] a = [6, 5, 4, 3, 2, 1]
a[eval("(...3)")] = 9 a[(...3)] = 9
a.should == [9, 3, 2, 1] a.should == [9, 3, 2, 1]
a[eval("(..2)")] = [7, 7, 7, 7, 7] a[(..2)] = [7, 7, 7, 7, 7]
a.should == [7, 7, 7, 7, 7, 1] a.should == [7, 7, 7, 7, 7, 1]
end end
it "replaces the section if n < 0" do it "replaces the section if n < 0" do
a = [1, 2, 3, 4, 5] a = [1, 2, 3, 4, 5]
a[eval("(..-2)")] = [7, 8, 9] a[(..-2)] = [7, 8, 9]
a.should == [7, 8, 9, 5] a.should == [7, 8, 9, 5]
end end
it "replaces everything if n > the array size" do it "replaces everything if n > the array size" do
a = [1, 2, 3] a = [1, 2, 3]
a[eval("(...7)")] = [4] a[(...7)] = [4]
a.should == [4] a.should == [4]
end end
it "inserts at the beginning if n < negative the array size" do it "inserts at the beginning if n < negative the array size" do
a = [1, 2, 3] a = [1, 2, 3]
a[eval("(..-7)")] = [4] a[(..-7)] = [4]
a.should == [4, 1, 2, 3] a.should == [4, 1, 2, 3]
a[eval("(...-10)")] = [6] a[(...-10)] = [6]
a.should == [6, 4, 1, 2, 3] a.should == [6, 4, 1, 2, 3]
end end
end end
end
describe "Array#[] after a shift" do describe "Array#[] after a shift" do
it "works for insertion" do it "works for insertion" do

View file

@ -323,10 +323,8 @@ describe "Array#fill with (filler, range)" do
[1, 2, 3, 4].fill(eval("(3...)")) { |x| x + 2 }.should == [1, 2, 3, 5] [1, 2, 3, 4].fill(eval("(3...)")) { |x| x + 2 }.should == [1, 2, 3, 5]
end end
ruby_version_is "2.7" do
it "works with beginless ranges" do it "works with beginless ranges" do
[1, 2, 3, 4].fill('x', eval("(..2)")).should == ["x", "x", "x", 4] [1, 2, 3, 4].fill('x', (..2)).should == ["x", "x", "x", 4]
[1, 2, 3, 4].fill(eval("(...2)")) { |x| x + 2 }.should == [2, 3, 3, 4] [1, 2, 3, 4].fill((...2)) { |x| x + 2 }.should == [2, 3, 3, 4]
end
end end
end end

View file

@ -147,16 +147,6 @@ describe "Array#flatten" do
end end
end end
ruby_version_is ''...'2.7' do
it "returns a tainted array if self is tainted" do
[].taint.flatten.tainted?.should be_true
end
it "returns an untrusted array if self is untrusted" do
[].untrust.flatten.untrusted?.should be_true
end
end
it "performs respond_to? and method_missing-aware checks when coercing elements to array" do it "performs respond_to? and method_missing-aware checks when coercing elements to array" do
bo = BasicObject.new bo = BasicObject.new
[bo].flatten.should == [bo] [bo].flatten.should == [bo]

View file

@ -6,7 +6,6 @@ describe "Array#&" do
it_behaves_like :array_intersection, :& it_behaves_like :array_intersection, :&
end end
ruby_version_is "2.7" do
describe "Array#intersection" do describe "Array#intersection" do
it_behaves_like :array_intersection, :intersection it_behaves_like :array_intersection, :intersection
@ -18,4 +17,3 @@ ruby_version_is "2.7" do
[1, 2, 3, 4].intersection([3, 2, 1]).should == [1, 2, 3] [1, 2, 3, 4].intersection([3, 2, 1]).should == [1, 2, 3]
end end
end end
end

View file

@ -97,46 +97,6 @@ describe "Array#* with an integer" do
ScratchPad.recorded.should be_nil ScratchPad.recorded.should be_nil
end end
end end
ruby_version_is ''...'2.7' do
it "copies the taint status of the original array even if the passed count is 0" do
ary = [1, 2, 3]
ary.taint
(ary * 0).should.tainted?
end
it "copies the taint status of the original array even if the array is empty" do
ary = []
ary.taint
(ary * 3).should.tainted?
end
it "copies the taint status of the original array if the passed count is not 0" do
ary = [1, 2, 3]
ary.taint
(ary * 1).should.tainted?
(ary * 2).should.tainted?
end
it "copies the untrusted status of the original array even if the passed count is 0" do
ary = [1, 2, 3]
ary.untrust
(ary * 0).should.untrusted?
end
it "copies the untrusted status of the original array even if the array is empty" do
ary = []
ary.untrust
(ary * 3).should.untrusted?
end
it "copies the untrusted status of the original array if the passed count is not 0" do
ary = [1, 2, 3]
ary.untrust
(ary * 1).should.untrusted?
(ary * 2).should.untrusted?
end
end
end end
describe "Array#* with a string" do describe "Array#* with a string" do

View file

@ -15,18 +15,6 @@ describe "Array#pack with format 'P'" do
["hello"].pack("P").unpack("P5").should == ["hello"] ["hello"].pack("P").unpack("P5").should == ["hello"]
end end
ruby_version_is ''...'2.7' do
it "taints the input string" do
input_string = "hello"
[input_string].pack("P")
input_string.tainted?.should be_true
end
it "does not taint the output string in normal cases" do
["hello"].pack("P").tainted?.should be_false
end
end
it "with nil gives a null pointer" do it "with nil gives a null pointer" do
[nil].pack("P").unpack("J").should == [0] [nil].pack("P").unpack("J").should == [0]
end end
@ -44,18 +32,6 @@ describe "Array#pack with format 'p'" do
["hello"].pack("p").unpack("p").should == ["hello"] ["hello"].pack("p").unpack("p").should == ["hello"]
end end
ruby_version_is ''...'2.7' do
it "taints the input string" do
input_string = "hello"
[input_string].pack("p")
input_string.tainted?.should be_true
end
it "does not taint the output string in normal cases" do
["hello"].pack("p").tainted?.should be_false
end
end
it "with nil gives a null pointer" do it "with nil gives a null pointer" do
[nil].pack("p").unpack("J").should == [0] [nil].pack("p").unpack("J").should == [0]
end end

View file

@ -32,12 +32,6 @@ describe :array_pack_basic_non_float, shared: true do
d.should_receive(:to_str).and_return("x"+pack_format) d.should_receive(:to_str).and_return("x"+pack_format)
[@obj, @obj].pack(d).should be_an_instance_of(String) [@obj, @obj].pack(d).should be_an_instance_of(String)
end end
ruby_version_is ''...'2.7' do
it "taints the output string if the format string is tainted" do
[@obj, @obj].pack("x"+pack_format.taint).tainted?.should be_true
end
end
end end
describe :array_pack_basic_float, shared: true do describe :array_pack_basic_float, shared: true do
@ -50,12 +44,6 @@ describe :array_pack_basic_float, shared: true do
d.should_receive(:to_str).and_return("x"+pack_format) d.should_receive(:to_str).and_return("x"+pack_format)
[1.2, 4.7].pack(d).should be_an_instance_of(String) [1.2, 4.7].pack(d).should be_an_instance_of(String)
end end
ruby_version_is ''...'2.7' do
it "taints the output string if the format string is tainted" do
[3.2, 2.8].pack("x"+pack_format.taint).tainted?.should be_true
end
end
end end
describe :array_pack_no_platform, shared: true do describe :array_pack_no_platform, shared: true do

View file

@ -1,35 +1,2 @@
describe :array_pack_taint, shared: true do describe :array_pack_taint, shared: true do
ruby_version_is ''...'2.7' do
it "returns a tainted string when a pack argument is tainted" do
["abcd".taint, 0x20].pack(pack_format("3C")).tainted?.should be_true
end
it "does not return a tainted string when the array is tainted" do
["abcd", 0x20].taint.pack(pack_format("3C")).tainted?.should be_false
end
it "returns a tainted string when the format is tainted" do
["abcd", 0x20].pack(pack_format("3C").taint).tainted?.should be_true
end
it "returns a tainted string when an empty format is tainted" do
["abcd", 0x20].pack("".taint).tainted?.should be_true
end
it "returns a untrusted string when the format is untrusted" do
["abcd", 0x20].pack(pack_format("3C").untrust).untrusted?.should be_true
end
it "returns a untrusted string when the empty format is untrusted" do
["abcd", 0x20].pack("".untrust).untrusted?.should be_true
end
it "returns a untrusted string when a pack argument is untrusted" do
["abcd".untrust, 0x20].pack(pack_format("3C")).untrusted?.should be_true
end
it "returns a trusted string when the array is untrusted" do
["abcd", 0x20].untrust.pack(pack_format("3C")).untrusted?.should be_false
end
end
end end

View file

@ -40,20 +40,4 @@ describe "Array#+" do
it "does not call to_ary on array subclasses" do it "does not call to_ary on array subclasses" do
([5, 6] + ArraySpecs::ToAryArray[1, 2]).should == [5, 6, 1, 2] ([5, 6] + ArraySpecs::ToAryArray[1, 2]).should == [5, 6, 1, 2]
end end
ruby_version_is ''...'2.7' do
it "does not get infected even if an original array is tainted" do
([1, 2] + [3, 4]).tainted?.should be_false
([1, 2].taint + [3, 4]).tainted?.should be_false
([1, 2] + [3, 4].taint).tainted?.should be_false
([1, 2].taint + [3, 4].taint).tainted?.should be_false
end
it "does not infected even if an original array is untrusted" do
([1, 2] + [3, 4]).untrusted?.should be_false
([1, 2].untrust + [3, 4]).untrusted?.should be_false
([1, 2] + [3, 4].untrust).untrusted?.should be_false
([1, 2].untrust + [3, 4].untrust).untrusted?.should be_false
end
end
end end

View file

@ -30,16 +30,6 @@ describe "Array#pop" do
array.pop.should == [1, 'two', 3.0, array, array, array, array] array.pop.should == [1, 'two', 3.0, array, array, array, array]
end end
ruby_version_is ''...'2.7' do
it "keeps taint status" do
a = [1, 2].taint
a.pop
a.tainted?.should be_true
a.pop
a.tainted?.should be_true
end
end
it "raises a FrozenError on a frozen array" do it "raises a FrozenError on a frozen array" do
-> { ArraySpecs.frozen_array.pop }.should raise_error(FrozenError) -> { ArraySpecs.frozen_array.pop }.should raise_error(FrozenError)
end end
@ -48,16 +38,6 @@ describe "Array#pop" do
-> { ArraySpecs.empty_frozen_array.pop }.should raise_error(FrozenError) -> { ArraySpecs.empty_frozen_array.pop }.should raise_error(FrozenError)
end end
ruby_version_is ''...'2.7' do
it "keeps untrusted status" do
a = [1, 2].untrust
a.pop
a.untrusted?.should be_true
a.pop
a.untrusted?.should be_true
end
end
describe "passed a number n as an argument" do describe "passed a number n as an argument" do
it "removes and returns an array with the last n elements of the array" do it "removes and returns an array with the last n elements of the array" do
a = [1, 2, 3, 4, 5, 6] a = [1, 2, 3, 4, 5, 6]
@ -136,41 +116,9 @@ describe "Array#pop" do
ArraySpecs::MyArray[1, 2, 3].pop(2).should be_an_instance_of(Array) ArraySpecs::MyArray[1, 2, 3].pop(2).should be_an_instance_of(Array)
end end
ruby_version_is ''...'2.7' do
it "returns an untainted array even if the array is tainted" do
ary = [1, 2].taint
ary.pop(2).tainted?.should be_false
ary.pop(0).tainted?.should be_false
end
it "keeps taint status" do
a = [1, 2].taint
a.pop(2)
a.tainted?.should be_true
a.pop(2)
a.tainted?.should be_true
end
it "returns a trusted array even if the array is untrusted" do
ary = [1, 2].untrust
ary.pop(2).untrusted?.should be_false
ary.pop(0).untrusted?.should be_false
end
end
it "raises a FrozenError on a frozen array" do it "raises a FrozenError on a frozen array" do
-> { ArraySpecs.frozen_array.pop(2) }.should raise_error(FrozenError) -> { ArraySpecs.frozen_array.pop(2) }.should raise_error(FrozenError)
-> { ArraySpecs.frozen_array.pop(0) }.should raise_error(FrozenError) -> { ArraySpecs.frozen_array.pop(0) }.should raise_error(FrozenError)
end end
ruby_version_is ''...'2.7' do
it "keeps untrusted status" do
a = [1, 2].untrust
a.pop(2)
a.untrusted?.should be_true
a.pop(2)
a.untrusted?.should be_true
end
end
end end
end end

View file

@ -17,28 +17,4 @@ describe :array_clone, shared: true do
b.should == a b.should == a
b.__id__.should_not == a.__id__ b.__id__.should_not == a.__id__
end end
ruby_version_is ''...'2.7' do
it "copies taint status from the original" do
a = [1, 2, 3, 4]
b = [1, 2, 3, 4]
a.taint
aa = a.send @method
bb = b.send @method
aa.should.tainted?
bb.should_not.tainted?
end
it "copies untrusted status from the original" do
a = [1, 2, 3, 4]
b = [1, 2, 3, 4]
a.untrust
aa = a.send @method
bb = b.send @method
aa.should.untrusted?
bb.should_not.untrusted?
end
end
end end

View file

@ -42,20 +42,6 @@ describe :array_collect, shared: true do
}.should raise_error(ArgumentError) }.should raise_error(ArgumentError)
end end
ruby_version_is ''...'2.7' do
it "does not copy tainted status" do
a = [1, 2, 3]
a.taint
a.send(@method){|x| x}.tainted?.should be_false
end
it "does not copy untrusted status" do
a = [1, 2, 3]
a.untrust
a.send(@method){|x| x}.untrusted?.should be_false
end
end
before :all do before :all do
@object = [1, 2, 3, 4] @object = [1, 2, 3, 4]
end end
@ -96,23 +82,6 @@ describe :array_collect_b, shared: true do
a.should == ["1!", "2!", "3!"] a.should == ["1!", "2!", "3!"]
end end
ruby_version_is ''...'2.7' do
it "keeps tainted status" do
a = [1, 2, 3]
a.taint
a.tainted?.should be_true
a.send(@method){|x| x}
a.tainted?.should be_true
end
it "keeps untrusted status" do
a = [1, 2, 3]
a.untrust
a.send(@method){|x| x}
a.untrusted?.should be_true
end
end
describe "when frozen" do describe "when frozen" do
it "raises a FrozenError" do it "raises a FrozenError" do
-> { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(FrozenError) -> { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(FrozenError)

View file

@ -64,32 +64,6 @@ describe :array_inspect, shared: true do
ArraySpecs.empty_recursive_array.send(@method).should == "[[...]]" ArraySpecs.empty_recursive_array.send(@method).should == "[[...]]"
end end
ruby_version_is ''...'2.7' do
it "taints the result if the Array is non-empty and tainted" do
[1, 2].taint.send(@method).tainted?.should be_true
end
it "does not taint the result if the Array is tainted but empty" do
[].taint.send(@method).tainted?.should be_false
end
it "taints the result if an element is tainted" do
["str".taint].send(@method).tainted?.should be_true
end
it "untrusts the result if the Array is untrusted" do
[1, 2].untrust.send(@method).untrusted?.should be_true
end
it "does not untrust the result if the Array is untrusted but empty" do
[].untrust.send(@method).untrusted?.should be_false
end
it "untrusts the result if an element is untrusted" do
["str".untrust].send(@method).untrusted?.should be_true
end
end
describe "with encoding" do describe "with encoding" do
before :each do before :each do
@default_external_encoding = Encoding.default_external @default_external_encoding = Encoding.default_external

View file

@ -58,36 +58,6 @@ describe :array_join_with_default_separator, shared: true do
-> { ArraySpecs.empty_recursive_array.send(@method) }.should raise_error(ArgumentError) -> { ArraySpecs.empty_recursive_array.send(@method) }.should raise_error(ArgumentError)
end end
ruby_version_is ''...'2.7' do
it "taints the result if the Array is tainted and non-empty" do
[1, 2].taint.send(@method).tainted?.should be_true
end
it "does not taint the result if the Array is tainted but empty" do
[].taint.send(@method).tainted?.should be_false
end
it "taints the result if the result of coercing an element is tainted" do
s = mock("taint")
s.should_receive(:to_s).and_return("str".taint)
[s].send(@method).tainted?.should be_true
end
it "untrusts the result if the Array is untrusted and non-empty" do
[1, 2].untrust.send(@method).untrusted?.should be_true
end
it "does not untrust the result if the Array is untrusted but empty" do
[].untrust.send(@method).untrusted?.should be_false
end
it "untrusts the result if the result of coercing an element is untrusted" do
s = mock("untrust")
s.should_receive(:to_s).and_return("str".untrust)
[s].send(@method).untrusted?.should be_true
end
end
it "uses the first encoding when other strings are compatible" do it "uses the first encoding when other strings are compatible" do
ary1 = ArraySpecs.array_with_7bit_utf8_and_usascii_strings ary1 = ArraySpecs.array_with_7bit_utf8_and_usascii_strings
ary2 = ArraySpecs.array_with_usascii_and_7bit_utf8_strings ary2 = ArraySpecs.array_with_usascii_and_7bit_utf8_strings
@ -114,7 +84,6 @@ describe :array_join_with_default_separator, shared: true do
-> { ary_utf8_bad_binary.send(@method) }.should raise_error(EncodingError) -> { ary_utf8_bad_binary.send(@method) }.should raise_error(EncodingError)
end end
ruby_version_is "2.7" do
context "when $, is not nil" do context "when $, is not nil" do
before do before do
suppress_warning do suppress_warning do
@ -128,7 +97,6 @@ describe :array_join_with_default_separator, shared: true do
end end
end end
end end
end
describe :array_join_with_string_separator, shared: true do describe :array_join_with_string_separator, shared: true do
it "returns a string formed by concatenating each element.to_str separated by separator" do it "returns a string formed by concatenating each element.to_str separated by separator" do
@ -141,42 +109,4 @@ describe :array_join_with_string_separator, shared: true do
[1, [2, [3, 4], 5], 6].send(@method, ":").should == "1:2:3:4:5:6" [1, [2, [3, 4], 5], 6].send(@method, ":").should == "1:2:3:4:5:6"
[1, [2, ArraySpecs::MyArray[3, 4], 5], 6].send(@method, ":").should == "1:2:3:4:5:6" [1, [2, ArraySpecs::MyArray[3, 4], 5], 6].send(@method, ":").should == "1:2:3:4:5:6"
end end
ruby_version_is ''...'2.7' do
describe "with a tainted separator" do
before :each do
@sep = ":".taint
end
it "does not taint the result if the array is empty" do
[].send(@method, @sep).tainted?.should be_false
end
it "does not taint the result if the array has only one element" do
[1].send(@method, @sep).tainted?.should be_false
end
it "taints the result if the array has two or more elements" do
[1, 2].send(@method, @sep).tainted?.should be_true
end
end
describe "with an untrusted separator" do
before :each do
@sep = ":".untrust
end
it "does not untrust the result if the array is empty" do
[].send(@method, @sep).untrusted?.should be_false
end
it "does not untrust the result if the array has only one element" do
[1].send(@method, @sep).untrusted?.should be_false
end
it "untrusts the result if the array has two or more elements" do
[1, 2].send(@method, @sep).untrusted?.should be_true
end
end
end
end end

View file

@ -556,34 +556,34 @@ describe :array_slice, shared: true do
it "has beginless range and positive steps" do it "has beginless range and positive steps" do
# end with zero index # end with zero index
@array.send(@method, eval("(..0).step(1)")).should == [0] @array.send(@method, (..0).step(1)).should == [0]
@array.send(@method, eval("(...0).step(1)")).should == [] @array.send(@method, (...0).step(1)).should == []
@array.send(@method, eval("(..0).step(2)")).should == [0] @array.send(@method, (..0).step(2)).should == [0]
@array.send(@method, eval("(...0).step(2)")).should == [] @array.send(@method, (...0).step(2)).should == []
@array.send(@method, eval("(..0).step(10)")).should == [0] @array.send(@method, (..0).step(10)).should == [0]
@array.send(@method, eval("(...0).step(10)")).should == [] @array.send(@method, (...0).step(10)).should == []
# end with positive index # end with positive index
@array.send(@method, eval("(..3).step(1)")).should == [0, 1, 2, 3] @array.send(@method, (..3).step(1)).should == [0, 1, 2, 3]
@array.send(@method, eval("(...3).step(1)")).should == [0, 1, 2] @array.send(@method, (...3).step(1)).should == [0, 1, 2]
@array.send(@method, eval("(..3).step(2)")).should == [0, 2] @array.send(@method, (..3).step(2)).should == [0, 2]
@array.send(@method, eval("(...3).step(2)")).should == [0, 2] @array.send(@method, (...3).step(2)).should == [0, 2]
@array.send(@method, eval("(..3).step(10)")).should == [0] @array.send(@method, (..3).step(10)).should == [0]
@array.send(@method, eval("(...3).step(10)")).should == [0] @array.send(@method, (...3).step(10)).should == [0]
# end with negative index # end with negative index
@array.send(@method, eval("(..-2).step(1)")).should == [0, 1, 2, 3, 4,] @array.send(@method, (..-2).step(1)).should == [0, 1, 2, 3, 4,]
@array.send(@method, eval("(...-2).step(1)")).should == [0, 1, 2, 3] @array.send(@method, (...-2).step(1)).should == [0, 1, 2, 3]
@array.send(@method, eval("(..-2).step(2)")).should == [0, 2, 4] @array.send(@method, (..-2).step(2)).should == [0, 2, 4]
@array.send(@method, eval("(...-2).step(2)")).should == [0, 2] @array.send(@method, (...-2).step(2)).should == [0, 2]
@array.send(@method, eval("(..-2).step(10)")).should == [0] @array.send(@method, (..-2).step(10)).should == [0]
@array.send(@method, eval("(...-2).step(10)")).should == [0] @array.send(@method, (...-2).step(10)).should == [0]
end end
it "has endless range and negative steps" do it "has endless range and negative steps" do
@ -770,26 +770,24 @@ describe :array_slice, shared: true do
end end
end end
ruby_version_is "2.7" do
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]
a.send(@method, eval("(..3)")).should == [0, 1, 2, 3] a.send(@method, (..3)).should == [0, 1, 2, 3]
a.send(@method, eval("(...3)")).should == [0, 1, 2] a.send(@method, (...3)).should == [0, 1, 2]
a.send(@method, eval("(..-3)")).should == [0, 1, 2, 3] a.send(@method, (..-3)).should == [0, 1, 2, 3]
a.send(@method, eval("(...-3)")).should == [0, 1, 2] a.send(@method, (...-3)).should == [0, 1, 2]
a.send(@method, eval("(..0)")).should == [0] a.send(@method, (..0)).should == [0]
a.send(@method, eval("(...0)")).should == [] a.send(@method, (...0)).should == []
a.send(@method, eval("(..9)")).should == [0, 1, 2, 3, 4, 5] a.send(@method, (..9)).should == [0, 1, 2, 3, 4, 5]
a.send(@method, eval("(...9)")).should == [0, 1, 2, 3, 4, 5] a.send(@method, (...9)).should == [0, 1, 2, 3, 4, 5]
a.send(@method, eval("(..-9)")).should == [] a.send(@method, (..-9)).should == []
a.send(@method, eval("(...-9)")).should == [] a.send(@method, (...-9)).should == []
end end
it "can accept nil...nil ranges" do it "can accept nil...nil ranges" do
a = [0, 1, 2, 3, 4, 5] a = [0, 1, 2, 3, 4, 5]
a.send(@method, eval("(nil...nil)")).should == a a.send(@method, eval("(nil...nil)")).should == a
a.send(@method, eval("(...nil)")).should == a a.send(@method, (...nil)).should == a
a.send(@method, eval("(nil..)")).should == a a.send(@method, eval("(nil..)")).should == a
end end
end end
end

View file

@ -116,21 +116,5 @@ describe "Array#shift" do
it "does not return subclass instances with Array subclass" do it "does not return subclass instances with Array subclass" do
ArraySpecs::MyArray[1, 2, 3].shift(2).should be_an_instance_of(Array) ArraySpecs::MyArray[1, 2, 3].shift(2).should be_an_instance_of(Array)
end end
ruby_version_is ''...'2.7' do
it "returns an untainted array even if the array is tainted" do
ary = [1, 2].taint
ary.shift(2).tainted?.should be_false
ary.shift(0).tainted?.should be_false
end
it "keeps taint status" do
a = [1, 2].taint
a.shift(2)
a.tainted?.should be_true
a.shift(2)
a.tainted?.should be_true
end
end
end end
end end

View file

@ -172,17 +172,15 @@ describe "Array#slice!" do
a.should == [1, 2] a.should == [1, 2]
end end
ruby_version_is "2.7" do
it "works with beginless ranges" do it "works with beginless ranges" do
a = [0,1,2,3,4] a = [0,1,2,3,4]
a.slice!(eval("(..3)")).should == [0, 1, 2, 3] a.slice!((..3)).should == [0, 1, 2, 3]
a.should == [4] a.should == [4]
a = [0,1,2,3,4] a = [0,1,2,3,4]
a.slice!(eval("(...-2)")).should == [0, 1, 2] a.slice!((...-2)).should == [0, 1, 2]
a.should == [3, 4] a.should == [3, 4]
end end
end
describe "with a subclass of Array" do describe "with a subclass of Array" do
before :each do before :each do

View file

@ -39,7 +39,6 @@ describe "Array#uniq" do
[x, y].uniq.should == [x, y] [x, y].uniq.should == [x, y]
end end
ruby_version_is '2.7' do
it "compares elements with matching hash codes with #eql?" do it "compares elements with matching hash codes with #eql?" do
a = Array.new(2) do a = Array.new(2) do
obj = mock('0') obj = mock('0')
@ -67,49 +66,6 @@ describe "Array#uniq" do
a.uniq.size.should == 1 a.uniq.size.should == 1
end end
end
ruby_version_is ''...'2.7' do
it "compares elements with matching hash codes with #eql?" do
a = Array.new(2) do
obj = mock('0')
obj.should_receive(:hash).at_least(1).and_return(0)
def obj.eql?(o)
# It's undefined whether the impl does a[0].eql?(a[1]) or
# a[1].eql?(a[0]) so we taint both.
taint
o.taint
false
end
obj
end
a.uniq.should == a
a[0].should.tainted?
a[1].should.tainted?
a = Array.new(2) do
obj = mock('0')
obj.should_receive(:hash).at_least(1).and_return(0)
def obj.eql?(o)
# It's undefined whether the impl does a[0].eql?(a[1]) or
# a[1].eql?(a[0]) so we taint both.
taint
o.taint
true
end
obj
end
a.uniq.size.should == 1
a[0].should.tainted?
a[1].should.tainted?
end
end
it "compares elements based on the value returned from the block" do it "compares elements based on the value returned from the block" do
a = [1, 2, 3, 4] a = [1, 2, 3, 4]

View file

@ -66,10 +66,8 @@ describe "Array#values_at" do
[1, 2, 3, 4].values_at(eval("(3...)")).should == [4] [1, 2, 3, 4].values_at(eval("(3...)")).should == [4]
end end
ruby_version_is "2.7" do
it "works when given beginless ranges" do it "works when given beginless ranges" do
[1, 2, 3, 4].values_at(eval("(..2)")).should == [1, 2, 3] [1, 2, 3, 4].values_at((..2)).should == [1, 2, 3]
[1, 2, 3, 4].values_at(eval("(...2)")).should == [1, 2] [1, 2, 3, 4].values_at((...2)).should == [1, 2]
end
end end
end end

View file

@ -49,15 +49,7 @@ describe "RUBY_RELEASE_DATE" do
end end
describe "RUBY_REVISION" do describe "RUBY_REVISION" do
ruby_version_is ""..."2.7" do
it "is an Integer" do
RUBY_REVISION.should be_kind_of(Integer)
end
end
ruby_version_is "2.7" do
it "is a String" do it "is a String" do
RUBY_REVISION.should be_kind_of(String) RUBY_REVISION.should be_kind_of(String)
end end
end end
end

View file

@ -2,14 +2,6 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
describe 'Comparable#clamp' do describe 'Comparable#clamp' do
ruby_version_is ""..."2.7" do
it 'raises an Argument error unless given 2 parameters' do
c = ComparableSpecs::Weird.new(0)
-> { c.clamp(c) }.should raise_error(ArgumentError)
-> { c.clamp(c, c, c) }.should raise_error(ArgumentError)
end
end
it 'raises an Argument error unless the 2 parameters are correctly ordered' do it 'raises an Argument error unless the 2 parameters are correctly ordered' do
one = ComparableSpecs::WithOnlyCompareDefined.new(1) one = ComparableSpecs::WithOnlyCompareDefined.new(1)
two = ComparableSpecs::WithOnlyCompareDefined.new(2) two = ComparableSpecs::WithOnlyCompareDefined.new(2)
@ -48,7 +40,6 @@ describe 'Comparable#clamp' do
c.clamp(one, two).should equal(two) c.clamp(one, two).should equal(two)
end end
ruby_version_is "2.7" do
it 'returns self if within the given range parameters' do it 'returns self if within the given range parameters' do
one = ComparableSpecs::WithOnlyCompareDefined.new(1) one = ComparableSpecs::WithOnlyCompareDefined.new(1)
two = ComparableSpecs::WithOnlyCompareDefined.new(2) two = ComparableSpecs::WithOnlyCompareDefined.new(2)
@ -85,4 +76,3 @@ describe 'Comparable#clamp' do
-> { c.clamp(one...two) }.should raise_error(ArgumentError) -> { c.clamp(one...two) }.should raise_error(ArgumentError)
end end
end end
end

View file

@ -1,7 +1,6 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
describe "Complex#<=>" do describe "Complex#<=>" do
ruby_version_is "2.7" do
it "returns nil if either self or argument has imaginary part" do it "returns nil if either self or argument has imaginary part" do
(Complex(5, 1) <=> Complex(2)).should be_nil (Complex(5, 1) <=> Complex(2)).should be_nil
(Complex(1) <=> Complex(2, 1)).should be_nil (Complex(1) <=> Complex(2, 1)).should be_nil
@ -24,4 +23,3 @@ describe "Complex#<=>" do
(Complex(2) <=> 2).should == 0 (Complex(2) <=> 2).should == 0
end end
end end
end

View file

@ -105,14 +105,6 @@ describe "Dir#children" do
dirs.each { |d| d.encoding.should == Encoding::UTF_8 } dirs.each { |d| d.encoding.should == Encoding::UTF_8 }
end end
ruby_version_is ""..."2.7" do
it "accepts nil options" do
@dir = Dir.new("#{DirSpecs.mock_dir}/deeply/nested", nil)
dirs = @dir.to_a.sort
dirs.each { |d| d.encoding.should == Encoding.find("filesystem") }
end
end
it "returns children encoded with the filesystem encoding by default" do it "returns children encoded with the filesystem encoding by default" do
# This spec depends on the locale not being US-ASCII because if it is, the # This spec depends on the locale not being US-ASCII because if it is, the
# children that are not ascii_only? will be BINARY encoded. # children that are not ascii_only? will be BINARY encoded.

View file

@ -15,13 +15,6 @@ describe "Dir.each_child" do
dirs.each {|dir| dir.encoding.should == Encoding::UTF_8} dirs.each {|dir| dir.encoding.should == Encoding::UTF_8}
end end
ruby_version_is ""..."2.7" do
it "accepts nil options" do
dirs = Dir.each_child("#{DirSpecs.mock_dir}/deeply/nested", nil).to_a.sort
dirs.each {|dir| dir.encoding.should == Encoding.find("filesystem")}
end
end
it "yields all names in an existing directory to the provided block" do it "yields all names in an existing directory to the provided block" do
a, b = [], [] a, b = [], []

View file

@ -40,13 +40,6 @@ describe "Dir.entries" do
dirs.each {|dir| dir.encoding.should == Encoding::UTF_8} dirs.each {|dir| dir.encoding.should == Encoding::UTF_8}
end end
ruby_version_is ""..."2.7" do
it "accepts nil options" do
dirs = Dir.entries("#{DirSpecs.mock_dir}/deeply/nested", nil).to_a.sort
dirs.each {|dir| dir.encoding.should == Encoding.find("filesystem")}
end
end
it "returns entries encoded with the filesystem encoding by default" do it "returns entries encoded with the filesystem encoding by default" do
# This spec depends on the locale not being US-ASCII because if it is, the # This spec depends on the locale not being US-ASCII because if it is, the
# entries that are not ascii_only? will be BINARY encoded. # entries that are not ascii_only? will be BINARY encoded.

View file

@ -51,13 +51,6 @@ describe "Dir.foreach" do
end end
end end
ruby_version_is ""..."2.7" do
it "accepts nil options" do
dirs = Dir.foreach("#{DirSpecs.mock_dir}/deeply/nested", nil).to_a.sort
dirs.each {|dir| dir.encoding.should == Encoding.find("filesystem")}
end
end
describe "when no block is given" do describe "when no block is given" do
it "returns an Enumerator" do it "returns an Enumerator" do
Dir.foreach(DirSpecs.mock_dir).should be_an_instance_of(Enumerator) Dir.foreach(DirSpecs.mock_dir).should be_an_instance_of(Enumerator)

View file

@ -23,20 +23,9 @@ describe :dir_glob, shared: true do
Dir.send(@method, obj).should == %w[file_one.ext] Dir.send(@method, obj).should == %w[file_one.ext]
end end
ruby_version_is ""..."2.7" do
it "splits the string on \\0 if there is only one string given and warns" do
-> {
Dir.send(@method, "file_o*\0file_t*").should ==
%w!file_one.ext file_two.ext!
}.should complain(/warning: use glob patterns list instead of nul-separated patterns/)
end
end
ruby_version_is "2.7" do
it "raises an ArgumentError if the string contains \\0" do it "raises an ArgumentError if the string contains \\0" 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
end
ruby_version_is "3.0" do ruby_version_is "3.0" do
it "result is sorted by default" do it "result is sorted by default" do

View file

@ -40,11 +40,9 @@ describe "Encoding.list" do
Encoding.list.should.include?(Encoding::UTF_8) Encoding.list.should.include?(Encoding::UTF_8)
end end
ruby_version_is "2.7" do
it 'includes CESU-8 encoding' do it 'includes CESU-8 encoding' do
Encoding.list.should.include?(Encoding::CESU_8) Encoding.list.should.include?(Encoding::CESU_8)
end end
end
# TODO: Find example that illustrates this # TODO: Find example that illustrates this
it "updates the list when #find is used to load a new encoding" it "updates the list when #find is used to load a new encoding"

View file

@ -1,7 +1,6 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
ruby_version_is '2.7' do
describe 'Enumerable#filter_map' do describe 'Enumerable#filter_map' do
before :each do before :each do
@numerous = EnumerableSpecs::Numerous.new(*(1..8).to_a) @numerous = EnumerableSpecs::Numerous.new(*(1..8).to_a)
@ -23,4 +22,3 @@ ruby_version_is '2.7' do
@numerous.filter_map.should be_an_instance_of(Enumerator) @numerous.filter_map.should be_an_instance_of(Enumerator)
end end
end end
end

View file

@ -33,15 +33,5 @@ describe "Enumerable#group_by" do
[3, 4, 5] => [[3, 4, 5]] } [3, 4, 5] => [[3, 4, 5]] }
end end
ruby_version_is ''...'2.7' do
it "returns a tainted hash if self is tainted" do
EnumerableSpecs::Empty.new.taint.group_by {}.tainted?.should be_true
end
it "returns an untrusted hash if self is untrusted" do
EnumerableSpecs::Empty.new.untrust.group_by {}.untrusted?.should be_true
end
end
it_behaves_like :enumerable_enumeratorized_with_origin_size, :group_by it_behaves_like :enumerable_enumeratorized_with_origin_size, :group_by
end end

View file

@ -13,14 +13,4 @@ describe :enumerable_entries, shared: true do
count.send(@method, :hello, "world").should == [1, 2, 3] count.send(@method, :hello, "world").should == [1, 2, 3]
count.arguments_passed.should == [:hello, "world"] count.arguments_passed.should == [:hello, "world"]
end end
ruby_version_is ''...'2.7' do
it "returns a tainted array if self is tainted" do
EnumerableSpecs::Empty.new.taint.send(@method).tainted?.should be_true
end
it "returns an untrusted array if self is untrusted" do
EnumerableSpecs::Empty.new.untrust.send(@method).untrusted?.should be_true
end
end
end end

View file

@ -18,6 +18,7 @@ describe :enumerable_inject, shared: true do
it "ignores the block if two arguments" do it "ignores the block if two arguments" do
EnumerableSpecs::Numerous.new(1, 2, 3).send(@method, 10, :-) { raise "we never get here"}.should == 4 EnumerableSpecs::Numerous.new(1, 2, 3).send(@method, 10, :-) { raise "we never get here"}.should == 4
[].send(@method, 3, :+) { raise "we never get here"}.should == 3
end end
it "can take a symbol argument" do it "can take a symbol argument" do

View file

@ -1,7 +1,6 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
ruby_version_is "2.7" do
describe "Enumerable#tally" do describe "Enumerable#tally" do
before :each do before :each do
ScratchPad.record [] ScratchPad.record []
@ -32,7 +31,6 @@ ruby_version_is "2.7" do
ScratchPad.recorded.should == [] ScratchPad.recorded.should == []
end end
end end
end
ruby_version_is "3.1" do ruby_version_is "3.1" do
describe "Enumerable#tally with a hash" do describe "Enumerable#tally with a hash" do

View file

@ -31,7 +31,6 @@ describe 'Enumerable#uniq' do
[x, y].to_enum.uniq.should == [x, y] [x, y].to_enum.uniq.should == [x, y]
end end
ruby_version_is '2.7' do
it "compares elements with matching hash codes with #eql?" do it "compares elements with matching hash codes with #eql?" do
a = Array.new(2) do a = Array.new(2) do
obj = mock('0') obj = mock('0')
@ -59,49 +58,6 @@ describe 'Enumerable#uniq' do
a.to_enum.uniq.size.should == 1 a.to_enum.uniq.size.should == 1
end end
end
ruby_version_is ''...'2.7' do
it "compares elements with matching hash codes with #eql?" do
a = Array.new(2) do
obj = mock('0')
obj.should_receive(:hash).at_least(1).and_return(0)
def obj.eql?(o)
# It's undefined whether the impl does a[0].eql?(a[1]) or
# a[1].eql?(a[0]) so we taint both.
taint
o.taint
false
end
obj
end
a.uniq.should == a
a[0].should.tainted?
a[1].should.tainted?
a = Array.new(2) do
obj = mock('0')
obj.should_receive(:hash).at_least(1).and_return(0)
def obj.eql?(o)
# It's undefined whether the impl does a[0].eql?(a[1]) or
# a[1].eql?(a[0]) so we taint both.
taint
o.taint
true
end
obj
end
a.to_enum.uniq.size.should == 1
a[0].should.tainted?
a[1].should.tainted?
end
end
context 'when yielded with multiple arguments' do context 'when yielded with multiple arguments' do
before :each do before :each do

View file

@ -7,12 +7,10 @@ describe "Enumerator::ArithmeticSequence#begin" do
(1...10).step.begin.should == 1 (1...10).step.begin.should == 1
end end
ruby_version_is "2.7" do
context "with beginless" do context "with beginless" do
it "returns nil as begin of the sequence" do it "returns nil as begin of the sequence" do
eval("(..10).step(1)").begin.should == nil (..10).step(1).begin.should == nil
eval("(...10).step(1)").begin.should == nil (...10).step(1).begin.should == nil
end
end end
end end
end end

View file

@ -1,6 +1,5 @@
require_relative '../../../spec_helper' require_relative '../../../spec_helper'
ruby_version_is "2.7" do
describe "Enumerator::Lazy#eager" do describe "Enumerator::Lazy#eager" do
it "returns a non-lazy Enumerator converted from the lazy enumerator" do it "returns a non-lazy Enumerator converted from the lazy enumerator" do
enum = [1, 2, 3].lazy enum = [1, 2, 3].lazy
@ -26,4 +25,3 @@ ruby_version_is "2.7" do
ScratchPad.recorded.should == [1, 2, 3] ScratchPad.recorded.should == [1, 2, 3]
end end
end end
end

View file

@ -3,7 +3,6 @@
require_relative '../../../spec_helper' require_relative '../../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
ruby_version_is "2.7" do
describe "Enumerator::Lazy#filter_map" do describe "Enumerator::Lazy#filter_map" do
it "maps only truthy results" do it "maps only truthy results" do
(1..Float::INFINITY).lazy.filter_map { |i| i if i.odd? }.first(4).should == [1, 3, 5, 7] (1..Float::INFINITY).lazy.filter_map { |i| i if i.odd? }.first(4).should == [1, 3, 5, 7]
@ -13,4 +12,3 @@ ruby_version_is "2.7" do
(1..Float::INFINITY).lazy.filter_map { |i| i.odd? ? i : false }.first(4).should == [1, 3, 5, 7] (1..Float::INFINITY).lazy.filter_map { |i| i.odd? ? i : false }.first(4).should == [1, 3, 5, 7]
end end
end end
end

View file

@ -3,7 +3,6 @@
require_relative '../../../spec_helper' require_relative '../../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
ruby_version_is "2.7" do
describe "Enumerator::Lazy#with_index" do describe "Enumerator::Lazy#with_index" do
it "enumerates with an index" do it "enumerates with an index" do
(0..Float::INFINITY).lazy.with_index.map { |i, idx| [i, idx] }.first(3).should == [[0, 0], [1, 1], [2, 2]] (0..Float::INFINITY).lazy.with_index.map { |i, idx| [i, idx] }.first(3).should == [[0, 0], [1, 1], [2, 2]]
@ -35,4 +34,3 @@ ruby_version_is "2.7" do
result.should == [[0,0], [1,1], [2,2], [0,0], [1,1], [2,2]] result.should == [[0,0], [1,1], [2,2], [0,0], [1,1], [2,2]]
end end
end end
end

View file

@ -77,7 +77,6 @@ describe "Enumerator.new" do
enum.take(3).should == [1, 2, 3] enum.take(3).should == [1, 2, 3]
end end
ruby_version_is "2.7" do
it "defines iteration with block, yielder argument and treating it as a proc" do it "defines iteration with block, yielder argument and treating it as a proc" do
enum = Enumerator.new do |yielder| enum = Enumerator.new do |yielder|
"a\nb\nc".each_line(&yielder) "a\nb\nc".each_line(&yielder)
@ -85,7 +84,6 @@ describe "Enumerator.new" do
enum.to_a.should == ["a\n", "b\n", "c"] enum.to_a.should == ["a\n", "b\n", "c"]
end end
end
describe 'yielded values' do describe 'yielded values' do
it 'handles yield arguments properly' do it 'handles yield arguments properly' do

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
ruby_version_is "2.7" do
describe "Enumerator.produce" do describe "Enumerator.produce" do
it "creates an infinite enumerator" do it "creates an infinite enumerator" do
enum = Enumerator.produce(0) { |prev| prev + 1 } enum = Enumerator.produce(0) { |prev| prev + 1 }
@ -33,4 +32,3 @@ ruby_version_is "2.7" do
end end
end end
end end
end

View file

@ -1,6 +1,5 @@
require_relative '../../../spec_helper' require_relative '../../../spec_helper'
ruby_version_is "2.7" do
describe "Enumerator::Yielder#to_proc" do describe "Enumerator::Yielder#to_proc" do
it "returns a Proc object that takes an argument and yields it to the block" do it "returns a Proc object that takes an argument and yields it to the block" do
ScratchPad.record [] ScratchPad.record []
@ -15,4 +14,3 @@ ruby_version_is "2.7" do
result.should == "foobar" result.should == "foobar"
end end
end end
end

View file

@ -1,8 +1,6 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
require_relative 'shared/update' require_relative 'shared/update'
ruby_version_is "2.7" do
describe "ENV.merge!" do describe "ENV.merge!" do
it_behaves_like :env_update, :merge! it_behaves_like :env_update, :merge!
end end
end

View file

@ -39,7 +39,6 @@ describe :env_update, shared: true do
ENV["bar"].should == "5" ENV["bar"].should == "5"
end end
ruby_version_is "2.7" do
# BUG: https://bugs.ruby-lang.org/issues/16192 # BUG: https://bugs.ruby-lang.org/issues/16192
it "does not evaluate the block when the name is new" do it "does not evaluate the block when the name is new" do
ENV.delete("bar") ENV.delete("bar")
@ -56,7 +55,6 @@ describe :env_update, shared: true do
ENV["foo"].should == "0" ENV["foo"].should == "0"
ENV["bar"].should == "1" ENV["bar"].should == "1"
end end
end
it "returns ENV when block given" do it "returns ENV when block given" do
ENV.send(@method, {"foo" => "0", "bar" => "1"}){}.should equal(ENV) ENV.send(@method, {"foo" => "0", "bar" => "1"}){}.should equal(ENV)

View file

@ -1,16 +1,13 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
describe "FrozenError.new" do describe "FrozenError.new" do
ruby_version_is "2.7" do
it "should take optional receiver argument" do it "should take optional receiver argument" do
o = Object.new o = Object.new
FrozenError.new("msg", receiver: o).receiver.should equal(o) FrozenError.new("msg", receiver: o).receiver.should equal(o)
end end
end end
end
describe "FrozenError#receiver" do describe "FrozenError#receiver" do
ruby_version_is "2.7" do
it "should return frozen object that modification was attempted on" do it "should return frozen object that modification was attempted on" do
o = Object.new.freeze o = Object.new.freeze
begin begin
@ -23,4 +20,3 @@ describe "FrozenError#receiver" do
end end
end end
end end
end

View file

@ -5,7 +5,6 @@ describe "FalseClass#to_s" do
false.to_s.should == "false" false.to_s.should == "false"
end end
ruby_version_is "2.7" do
it "returns a frozen string" do it "returns a frozen string" do
false.to_s.should.frozen? false.to_s.should.frozen?
end end
@ -14,4 +13,3 @@ describe "FalseClass#to_s" do
false.to_s.should equal(false.to_s) false.to_s.should equal(false.to_s)
end end
end end
end

View file

@ -2,7 +2,6 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
require_relative '../../shared/kernel/raise' require_relative '../../shared/kernel/raise'
ruby_version_is "2.7" do
describe "Fiber#raise" do describe "Fiber#raise" do
it_behaves_like :kernel_raise, :raise, FiberSpecs::NewFiberToRaise it_behaves_like :kernel_raise, :raise, FiberSpecs::NewFiberToRaise
end end
@ -94,9 +93,8 @@ ruby_version_is "2.7" do
end end
end end
end
ruby_version_is "2.7"..."3.0" do 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 it "raises a FiberError if invoked on a transferring Fiber" do
require "fiber" require "fiber"

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
ruby_version_is "2.7" do
describe "File.absolute_path?" do describe "File.absolute_path?" do
before :each do before :each do
@abs = File.expand_path(__FILE__) @abs = File.expand_path(__FILE__)
@ -51,7 +50,6 @@ ruby_version_is "2.7" do
end end
end end
end end
end
describe "File.absolute_path" do describe "File.absolute_path" do
before :each do before :each do

View file

@ -33,14 +33,14 @@ describe "File.extname" do
end end
describe "for a filename ending with a dot" do describe "for a filename ending with a dot" do
guard -> { platform_is :windows or ruby_version_is ""..."2.7" } do platform_is :windows do
it "returns ''" do it "returns ''" do
File.extname(".foo.").should == "" File.extname(".foo.").should == ""
File.extname("foo.").should == "" File.extname("foo.").should == ""
end end
end end
guard -> { platform_is_not :windows and ruby_version_is "2.7" } do platform_is_not :windows do
it "returns '.'" do it "returns '.'" do
File.extname(".foo.").should == "." File.extname(".foo.").should == "."
File.extname("foo.").should == "." File.extname("foo.").should == "."

View file

@ -42,18 +42,6 @@ describe "Hash.[]" do
Hash[ary].should == { a: :b } Hash[ary].should == { a: :b }
end end
ruby_version_is "" ... "2.7" do
it "ignores elements that are not arrays" do
-> {
Hash[[:a]].should == {}
}.should complain(/ignoring wrong elements/)
-> {
Hash[[:nil]].should == {}
}.should complain(/ignoring wrong elements/)
end
end
ruby_version_is "2.7" do
it "raises for elements that are not arrays" do it "raises for elements that are not arrays" do
-> { -> {
Hash[[:a]].should == {} Hash[[:a]].should == {}
@ -62,7 +50,6 @@ describe "Hash.[]" do
Hash[[:nil]].should == {} Hash[[:nil]].should == {}
}.should raise_error(ArgumentError) }.should raise_error(ArgumentError)
end end
end
it "raises an ArgumentError for arrays of more than 2 elements" do it "raises an ArgumentError for arrays of more than 2 elements" do
->{ Hash[[[:a, :b, :c]]].should == {} }.should raise_error(ArgumentError) ->{ Hash[[[:a, :b, :c]]].should == {} }.should raise_error(ArgumentError)

View file

@ -1,6 +1,5 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
ruby_version_is "2.7" do
describe "Hash#deconstruct_keys" do describe "Hash#deconstruct_keys" do
it "returns self" do it "returns self" do
hash = {a: 1, b: 2} hash = {a: 1, b: 2}
@ -22,4 +21,3 @@ ruby_version_is "2.7" do
hash.deconstruct_keys('' ).should == {a: 1, b: 2} hash.deconstruct_keys('' ).should == {a: 1, b: 2}
end end
end end
end

View file

@ -31,13 +31,6 @@ describe "Hash#reject" do
HashSpecs::MyHash[1 => 2, 3 => 4].reject { false }.should be_kind_of(Hash) HashSpecs::MyHash[1 => 2, 3 => 4].reject { false }.should be_kind_of(Hash)
HashSpecs::MyHash[1 => 2, 3 => 4].reject { true }.should be_kind_of(Hash) HashSpecs::MyHash[1 => 2, 3 => 4].reject { true }.should be_kind_of(Hash)
end end
ruby_version_is ''...'2.7' do
it "does not taint the resulting hash" do
h = { a: 1 }.taint
h.reject {false}.should_not.tainted?
end
end
end end
it "processes entries with the same order as reject!" do it "processes entries with the same order as reject!" do

View file

@ -1,7 +1,6 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
ruby_version_is "2.7" do
describe "Hash.ruby2_keywords_hash?" do describe "Hash.ruby2_keywords_hash?" do
it "returns false if the Hash is not a keywords Hash" do it "returns false if the Hash is not a keywords Hash" do
Hash.ruby2_keywords_hash?({}).should == false Hash.ruby2_keywords_hash?({}).should == false
@ -58,4 +57,3 @@ ruby_version_is "2.7" do
-> { Hash.ruby2_keywords_hash(nil) }.should raise_error(TypeError) -> { Hash.ruby2_keywords_hash(nil) }.should raise_error(TypeError)
end end
end end
end

View file

@ -149,7 +149,6 @@ describe :hash_eql_additional, shared: true do
h.send(@method, HashSpecs::MyHash[h]).should be_true h.send(@method, HashSpecs::MyHash[h]).should be_true
end end
ruby_version_is '2.7' do
# Why isn't this true of eql? too ? # Why isn't this true of eql? too ?
it "compares keys with matching hash codes via eql?" do it "compares keys with matching hash codes via eql?" do
a = Array.new(2) do a = Array.new(2) do
@ -179,51 +178,6 @@ describe :hash_eql_additional, shared: true do
{ a[0] => 1 }.send(@method, { a[1] => 1 }).should be_true { a[0] => 1 }.send(@method, { a[1] => 1 }).should be_true
end end
end
ruby_version_is ''...'2.7' do
# Why isn't this true of eql? too ?
it "compares keys with matching hash codes via eql?" do
a = Array.new(2) do
obj = mock('0')
obj.should_receive(:hash).at_least(1).and_return(0)
# It's undefined whether the impl does a[0].eql?(a[1]) or
# a[1].eql?(a[0]) so we taint both.
def obj.eql?(o)
return true if self.equal?(o)
taint
o.taint
false
end
obj
end
{ a[0] => 1 }.send(@method, { a[1] => 1 }).should be_false
a[0].tainted?.should be_true
a[1].tainted?.should be_true
a = Array.new(2) do
obj = mock('0')
obj.should_receive(:hash).at_least(1).and_return(0)
def obj.eql?(o)
# It's undefined whether the impl does a[0].send(@method, a[1]) or
# a[1].send(@method, a[0]) so we taint both.
taint
o.taint
true
end
obj
end
{ a[0] => 1 }.send(@method, { a[1] => 1 }).should be_true
a[0].tainted?.should be_true
a[1].tainted?.should be_true
end
end
it "compares the values in self to values in other hash" do it "compares the values in self to values in other hash" do
l_val = mock("left") l_val = mock("left")

View file

@ -76,18 +76,6 @@ describe :hash_to_s, shared: true do
y.send(@method).should == "{1=>{0=>{...}}}" y.send(@method).should == "{1=>{0=>{...}}}"
end end
ruby_version_is ''...'2.7' do
it "returns a tainted string if self is tainted and not empty" do
{}.taint.send(@method).tainted?.should be_false
{ nil => nil }.taint.send(@method).tainted?.should be_true
end
it "returns an untrusted string if self is untrusted and not empty" do
{}.untrust.send(@method).untrusted?.should be_false
{ nil => nil }.untrust.send(@method).untrusted?.should be_true
end
end
it "does not raise if inspected result is not default external encoding" do it "does not raise if inspected result is not default external encoding" do
utf_16be = mock("utf_16be") utf_16be = mock("utf_16be")
utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE)) utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))

View file

@ -27,17 +27,7 @@ describe "Hash#to_a" do
ent.should == pairs ent.should == pairs
end end
ruby_version_is ''...'2.7' do ruby_version_is ''...'3.0' do
it "returns a tainted array if self is tainted" do
{}.taint.to_a.tainted?.should be_true
end
it "returns an untrusted array if self is untrusted" do
{}.untrust.to_a.untrusted?.should be_true
end
end
ruby_version_is '2.7'...'3.0' do
it "returns a not tainted array if self is tainted" do it "returns a not tainted array if self is tainted" do
{}.taint.to_a.tainted?.should be_false {}.taint.to_a.tainted?.should be_false
end end

View file

@ -245,7 +245,6 @@ describe "Integer#chr with an encoding argument" do
end end
end end
ruby_version_is "2.7" do
it 'returns a String encoding self interpreted as a codepoint in the CESU-8 encoding' do it 'returns a String encoding self interpreted as a codepoint in the CESU-8 encoding' do
# see more details here https://en.wikipedia.org/wiki/CESU-8 # see more details here https://en.wikipedia.org/wiki/CESU-8
# code points from U+0000 to U+FFFF is encoded in the same way as in UTF-8 # code points from U+0000 to U+FFFF is encoded in the same way as in UTF-8
@ -257,4 +256,3 @@ describe "Integer#chr with an encoding argument" do
0x10400.chr(Encoding::CESU_8).bytes.to_a.should == [0xED, 0xA0, 0x81, 0xED, 0xB0, 0x80] 0x10400.chr(Encoding::CESU_8).bytes.to_a.should == [0xED, 0xA0, 0x81, 0xED, 0xB0, 0x80]
end end
end end
end

View file

@ -79,7 +79,6 @@ describe "Integer#[]" do
3[bignum_value.to_f].should == 0 3[bignum_value.to_f].should == 0
end end
ruby_version_is "2.7" do
context "when index and length passed" do context "when index and length passed" do
it "returns specified number of bits from specified position" do it "returns specified number of bits from specified position" do
0b101001101[2, 4].should == 0b0011 0b101001101[2, 4].should == 0b0011
@ -157,7 +156,6 @@ describe "Integer#[]" do
end end
end end
end end
end
context "bignum" do context "bignum" do
before :each do before :each do

View file

@ -9,6 +9,52 @@ describe "Integer#fdiv" do
8.fdiv(bignum_value).should be_close(8.673617379884035e-19, TOLERANCE) 8.fdiv(bignum_value).should be_close(8.673617379884035e-19, TOLERANCE)
end end
it "performs floating-point division between self bignum and a bignum" do
num = 1000000000000000000000000000000000048148248609680896326399448564623182963452541226153892315137780403285956264146010000000000000000000000000000000000048148248609680896326399448564623182963452541226153892315137780403285956264146010000000000000000000000000000000000048148248609680896326399448564623182963452541226153892315137780403285956264146009
den = 2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
num.fdiv(den).should == 500.0
end
it "rounds to the correct value for bignums" do
den = 9 * 10**342
num = 1 * 10**344
num.fdiv(den).should == 11.11111111111111
num = 1 * 10**343
num.fdiv(den).should == 1.1111111111111112
num = 1 * 10**342
num.fdiv(den).should == 0.1111111111111111
num = 2 * 10**342
num.fdiv(den).should == 0.2222222222222222
num = 3 * 10**342
num.fdiv(den).should == 0.3333333333333333
num = 4 * 10**342
num.fdiv(den).should == 0.4444444444444444
num = 5 * 10**342
num.fdiv(den).should == 0.5555555555555556
num = 6 * 10**342
num.fdiv(den).should == 0.6666666666666666
num = 7 * 10**342
num.fdiv(den).should == 0.7777777777777778
num = 8 * 10**342
num.fdiv(den).should == 0.8888888888888888
num = 9 * 10**342
num.fdiv(den).should == 1.0
num = -5 * 10**342
num.fdiv(den).should == -0.5555555555555556
end
it "performs floating-point division between self and a Float" do it "performs floating-point division between self and a Float" do
8.fdiv(9.0).should be_close(0.888888888888889, TOLERANCE) 8.fdiv(9.0).should be_close(0.888888888888889, TOLERANCE)
end end

View file

@ -38,14 +38,6 @@ describe "IO#gets" do
IOSpecs.lines.each { |line| line.should == @io.gets } IOSpecs.lines.each { |line| line.should == @io.gets }
end end
ruby_version_is ''...'2.7' do
it "returns tainted strings" do
while line = @io.gets
line.should.tainted?
end
end
end
it "updates lineno with each invocation" do it "updates lineno with each invocation" do
while @io.gets while @io.gets
@io.lineno.should == @count += 1 @io.lineno.should == @count += 1
@ -64,14 +56,6 @@ describe "IO#gets" do
@io.gets(nil).should == IOSpecs.lines.join("") @io.gets(nil).should == IOSpecs.lines.join("")
end end
ruby_version_is ''...'2.7' do
it "returns tainted strings" do
while line = @io.gets(nil)
line.should.tainted?
end
end
end
it "updates lineno with each invocation" do it "updates lineno with each invocation" do
while @io.gets(nil) while @io.gets(nil)
@io.lineno.should == @count += 1 @io.lineno.should == @count += 1
@ -100,14 +84,6 @@ describe "IO#gets" do
@io.gets.should == IOSpecs.lines[4] @io.gets.should == IOSpecs.lines[4]
end end
ruby_version_is ''...'2.7' do
it "returns tainted strings" do
while line = @io.gets("")
line.should.tainted?
end
end
end
it "updates lineno with each invocation" do it "updates lineno with each invocation" do
while @io.gets("") while @io.gets("")
@io.lineno.should == @count += 1 @io.lineno.should == @count += 1
@ -126,14 +102,6 @@ describe "IO#gets" do
@io.gets("la linea").should == "Voici la ligne une.\nQui \303\250 la linea" @io.gets("la linea").should == "Voici la ligne une.\nQui \303\250 la linea"
end end
ruby_version_is ''...'2.7' do
it "returns tainted strings" do
while line = @io.gets("la")
line.should.tainted?
end
end
end
it "updates lineno with each invocation" do it "updates lineno with each invocation" do
while (@io.gets("la")) while (@io.gets("la"))
@io.lineno.should == @count += 1 @io.lineno.should == @count += 1

View file

@ -12,7 +12,6 @@ describe "IO#set_encoding_by_bom" do
rm_r @name rm_r @name
end end
ruby_version_is "2.7" do
it "returns the result encoding if found BOM UTF-8 sequence" do it "returns the result encoding if found BOM UTF-8 sequence" do
File.binwrite(@name, "\u{FEFF}abc") File.binwrite(@name, "\u{FEFF}abc")
@ -74,4 +73,3 @@ describe "IO#set_encoding_by_bom" do
-> { @io.set_encoding_by_bom }.should raise_error(ArgumentError, 'encoding conversion is set') -> { @io.set_encoding_by_bom }.should raise_error(ArgumentError, 'encoding conversion is set')
end end
end end
end

View file

@ -36,22 +36,12 @@ describe "IO#ungetbyte" do
@io.getbyte.should == 97 @io.getbyte.should == 97
end end
ruby_version_is ''...'2.6.1' do
it "is an RangeError if the integer is not in 8bit" do
for i in [4095, 0x4f7574206f6620636861722072616e6765] do
-> { @io.ungetbyte(i) }.should raise_error(RangeError)
end
end
end
ruby_version_is '2.6.1' do
it "never raises RangeError" do it "never raises RangeError" do
for i in [4095, 0x4f7574206f6620636861722072616e67ff] do for i in [4095, 0x4f7574206f6620636861722072616e67ff] do
@io.ungetbyte(i).should be_nil @io.ungetbyte(i).should be_nil
@io.getbyte.should == 255 @io.getbyte.should == 255
end end
end end
end
it "raises IOError on stream not opened for reading" do it "raises IOError on stream not opened for reading" do
-> { STDOUT.ungetbyte(42) }.should raise_error(IOError, "not opened for reading") -> { STDOUT.ungetbyte(42) }.should raise_error(IOError, "not opened for reading")

View file

@ -34,12 +34,10 @@ describe 'Kernel#caller_locations' do
locations2.map(&:to_s).should == locations1[2..-1].map(&:to_s) locations2.map(&:to_s).should == locations1[2..-1].map(&:to_s)
end end
ruby_version_is "2.7" do
it "works with beginless ranges" do it "works with beginless ranges" do
locations1 = caller_locations(0) locations1 = caller_locations(0)
locations2 = caller_locations(eval("(...5)")) locations2 = caller_locations((...5))
locations2.map(&:to_s)[eval("(2..)")].should == locations1[eval("(...5)")].map(&:to_s)[eval("(2..)")] locations2.map(&:to_s)[eval("(2..)")].should == locations1[(...5)].map(&:to_s)[eval("(2..)")]
end
end end
it "can be called with a range whose end is negative" do it "can be called with a range whose end is negative" do

View file

@ -50,12 +50,10 @@ describe 'Kernel#caller' do
locations2.map(&:to_s).should == locations1[2..-1].map(&:to_s) locations2.map(&:to_s).should == locations1[2..-1].map(&:to_s)
end end
ruby_version_is "2.7" do
it "works with beginless ranges" do it "works with beginless ranges" do
locations1 = KernelSpecs::CallerTest.locations(0) locations1 = KernelSpecs::CallerTest.locations(0)
locations2 = KernelSpecs::CallerTest.locations(eval("(..5)")) locations2 = KernelSpecs::CallerTest.locations((..5))
locations2.map(&:to_s)[eval("(2..)")].should == locations1[eval("(..5)")].map(&:to_s)[eval("(2..)")] locations2.map(&:to_s)[eval("(2..)")].should == locations1[(..5)].map(&:to_s)[eval("(2..)")]
end
end end
guard -> { Kernel.instance_method(:tap).source_location } do guard -> { Kernel.instance_method(:tap).source_location } do

View file

@ -206,11 +206,4 @@ describe "Kernel#clone" do
cloned.bar.should == ['a'] cloned.bar.should == ['a']
end end
ruby_version_is ''...'2.7' do
it 'copies tainted?' do
o = ''.taint.clone
o.tainted?.should be_true
end
end
end end

View file

@ -6,16 +6,6 @@ describe "Kernel#inspect" do
Object.new.inspect.should be_an_instance_of(String) Object.new.inspect.should be_an_instance_of(String)
end end
ruby_version_is ''...'2.7' do
it "returns a tainted string if self is tainted" do
Object.new.taint.inspect.tainted?.should be_true
end
it "returns an untrusted string if self is untrusted" do
Object.new.untrust.inspect.untrusted?.should be_true
end
end
it "does not call #to_s if it is defined" do it "does not call #to_s if it is defined" do
# We must use a bare Object here # We must use a bare Object here
obj = Object.new obj = Object.new

View file

@ -34,4 +34,28 @@ describe "Kernel#method" do
m.should be_an_instance_of(Method) m.should be_an_instance_of(Method)
m.call(1, 2, 3).should == "Done handled_privately([1, 2, 3])" m.call(1, 2, 3).should == "Done handled_privately([1, 2, 3])"
end end
it "can call a #method_missing accepting zero or one arguments" do
cls = Class.new do
def respond_to_missing?(name, *)
name == :foo or super
end
def method_missing
:no_args
end
end
m = cls.new.method(:foo)
-> { m.call }.should raise_error(ArgumentError)
cls = Class.new do
def respond_to_missing?(name, *)
name == :bar or super
end
def method_missing(m)
m
end
end
m = cls.new.method(:bar)
m.call.should == :bar
end
end end

View file

@ -40,15 +40,7 @@ describe "Kernel#proc" do
proc proc
end end
ruby_version_is ""..."2.7" do ruby_version_is ""..."3.0" do
it "uses the implicit block from an enclosing method" do
prc = some_method { "hello" }
prc.call.should == "hello"
end
end
ruby_version_is "2.7"..."3.0" do
it "can be created when called with no block" do it "can be created when called with no block" do
-> { -> {
some_method { "hello" } some_method { "hello" }

View file

@ -52,18 +52,6 @@ describe :kernel_dup_clone, shared: true do
o2.original.should equal(o) o2.original.should equal(o)
end end
ruby_version_is ''...'2.7' do
it "preserves tainted state from the original" do
o = ObjectSpecDupInitCopy.new
o2 = o.send(@method)
o.taint
o3 = o.send(@method)
o2.should_not.tainted?
o3.should.tainted?
end
end
it "does not preserve the object_id" do it "does not preserve the object_id" do
o1 = ObjectSpecDupInitCopy.new o1 = ObjectSpecDupInitCopy.new
old_object_id = o1.object_id old_object_id = o1.object_id
@ -71,18 +59,6 @@ describe :kernel_dup_clone, shared: true do
o2.object_id.should_not == old_object_id o2.object_id.should_not == old_object_id
end end
ruby_version_is ''...'2.7' do
it "preserves untrusted state from the original" do
o = ObjectSpecDupInitCopy.new
o2 = o.send(@method)
o.untrust
o3 = o.send(@method)
o2.should_not.untrusted?
o3.should.untrusted?
end
end
it "returns nil for NilClass" do it "returns nil for NilClass" do
nil.send(@method).should == nil nil.send(@method).should == nil
end end

View file

@ -251,7 +251,7 @@ describe :kernel_require, shared: true do
ScratchPad.recorded.should == [:loaded] ScratchPad.recorded.should == [:loaded]
end end
ruby_bug "#16926", "2.7"..."3.0" do 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
@ -547,9 +547,7 @@ describe :kernel_require, shared: true do
end end
provided = %w[complex enumerator rational thread] provided = %w[complex enumerator rational thread]
ruby_version_is "2.7" do
provided << 'ruby2_keywords' provided << 'ruby2_keywords'
end
it "#{provided.join(', ')} are already required" do it "#{provided.join(', ')} are already required" do
features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems') features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')

View file

@ -2,50 +2,7 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
describe "Kernel#taint" do describe "Kernel#taint" do
ruby_version_is ''...'2.7' do ruby_version_is ""..."3.0" do
it "returns self" do
o = Object.new
o.taint.should equal(o)
end
it "sets the tainted bit" do
o = Object.new
o.taint
o.should.tainted?
end
it "raises FrozenError on an untainted, frozen object" do
o = Object.new.freeze
-> { o.taint }.should raise_error(FrozenError)
end
it "does not raise an error on a tainted, frozen object" do
o = Object.new.taint.freeze
o.taint.should equal(o)
end
it "has no effect on immediate values" do
[nil, true, false].each do |v|
v.taint
v.should_not.tainted?
end
end
it "no raises a RuntimeError on symbols" do
v = :sym
-> { v.taint }.should_not raise_error(RuntimeError)
v.should_not.tainted?
end
it "no raises error on integer values" do
[1].each do |v|
-> { v.taint }.should_not raise_error(RuntimeError)
v.should_not.tainted?
end
end
end
ruby_version_is "2.7"..."3.0" do
it "is a no-op" do it "is a no-op" do
o = Object.new o = Object.new
o.taint o.taint

View file

@ -2,17 +2,7 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
describe "Kernel#tainted?" do describe "Kernel#tainted?" do
ruby_version_is ''...'2.7' do ruby_version_is ""..."3.0" do
it "returns true if Object is tainted" do
o = mock('o')
p = mock('p')
p.taint
o.should_not.tainted?
p.should.tainted?
end
end
ruby_version_is "2.7"..."3.0" do
it "is a no-op" do it "is a no-op" do
o = mock('o') o = mock('o')
p = mock('p') p = mock('p')

View file

@ -5,14 +5,4 @@ describe "Kernel#to_s" do
it "returns a String containing the name of self's class" do it "returns a String containing the name of self's class" do
Object.new.to_s.should =~ /Object/ Object.new.to_s.should =~ /Object/
end end
ruby_version_is ''...'2.7' do
it "returns a tainted result if self is tainted" do
Object.new.taint.to_s.tainted?.should be_true
end
it "returns an untrusted result if self is untrusted" do
Object.new.untrust.to_s.untrusted?.should be_true
end
end
end end

View file

@ -2,30 +2,7 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
describe "Kernel#trust" do describe "Kernel#trust" do
ruby_version_is ''...'2.7' do ruby_version_is ""..."3.0" do
it "returns self" do
o = Object.new
o.trust.should equal(o)
end
it "clears the untrusted bit" do
o = Object.new.untrust
o.trust
o.should_not.untrusted?
end
it "raises FrozenError on an untrusted, frozen object" do
o = Object.new.untrust.freeze
-> { o.trust }.should raise_error(FrozenError)
end
it "does not raise an error on a trusted, frozen object" do
o = Object.new.freeze
o.trust.should equal(o)
end
end
ruby_version_is "2.7"..."3.0" do
it "is a no-op" do it "is a no-op" do
o = Object.new.untrust o = Object.new.untrust
o.should_not.untrusted? o.should_not.untrusted?

View file

@ -2,30 +2,7 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
describe "Kernel#untaint" do describe "Kernel#untaint" do
ruby_version_is ''...'2.7' do ruby_version_is ""..."3.0" do
it "returns self" do
o = Object.new
o.untaint.should equal(o)
end
it "clears the tainted bit" do
o = Object.new.taint
o.untaint
o.should_not.tainted?
end
it "raises FrozenError on a tainted, frozen object" do
o = Object.new.taint.freeze
-> { o.untaint }.should raise_error(FrozenError)
end
it "does not raise an error on an untainted, frozen object" do
o = Object.new.freeze
o.untaint.should equal(o)
end
end
ruby_version_is "2.7"..."3.0" do
it "is a no-op" do it "is a no-op" do
o = Object.new.taint o = Object.new.taint
o.should_not.tainted? o.should_not.tainted?

View file

@ -2,30 +2,7 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
describe "Kernel#untrust" do describe "Kernel#untrust" do
ruby_version_is ''...'2.7' do ruby_version_is ""..."3.0" do
it "returns self" do
o = Object.new
o.untrust.should equal(o)
end
it "sets the untrusted bit" do
o = Object.new
o.untrust
o.should.untrusted?
end
it "raises FrozenError on a trusted, frozen object" do
o = Object.new.freeze
-> { o.untrust }.should raise_error(FrozenError)
end
it "does not raise an error on an untrusted, frozen object" do
o = Object.new.untrust.freeze
o.untrust.should equal(o)
end
end
ruby_version_is "2.7"..."3.0" do
it "is a no-op" do it "is a no-op" do
o = Object.new o = Object.new
o.untrust o.untrust

View file

@ -2,33 +2,7 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
describe "Kernel#untrusted?" do describe "Kernel#untrusted?" do
ruby_version_is ''...'2.7' do ruby_version_is ""..."3.0" do
it "returns the untrusted status of an object" do
o = mock('o')
o.should_not.untrusted?
o.untrust
o.should.untrusted?
end
it "has no effect on immediate values" do
a = nil
b = true
c = false
a.untrust
b.untrust
c.untrust
a.should_not.untrusted?
b.should_not.untrusted?
c.should_not.untrusted?
end
it "has effect on immediate values" do
d = 1
-> { d.untrust }.should_not raise_error(RuntimeError)
end
end
ruby_version_is "2.7"..."3.0" do
it "is a no-op" do it "is a no-op" do
o = mock('o') o = mock('o')
o.should_not.untrusted? o.should_not.untrusted?

View file

@ -1,11 +1,9 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
require_relative 'fixtures/classes' require_relative 'fixtures/classes'
ruby_version_is "2.7" do
describe "main.ruby2_keywords" do describe "main.ruby2_keywords" do
it "is the same as Object.ruby2_keywords" do it "is the same as Object.ruby2_keywords" do
main = TOPLEVEL_BINDING.receiver main = TOPLEVEL_BINDING.receiver
main.should have_private_method(:ruby2_keywords) main.should have_private_method(:ruby2_keywords)
end end
end end
end

View file

@ -604,30 +604,4 @@ describe "Marshal.dump" do
m = Mutex.new m = Mutex.new
-> { Marshal.dump(m) }.should raise_error(TypeError) -> { Marshal.dump(m) }.should raise_error(TypeError)
end end
ruby_version_is ''...'2.7' do
it "returns an untainted string if object is untainted" do
Marshal.dump(Object.new).tainted?.should be_false
end
it "returns a tainted string if object is tainted" do
Marshal.dump(Object.new.taint).tainted?.should be_true
end
it "returns a tainted string if nested object is tainted" do
Marshal.dump([[Object.new.taint]]).tainted?.should be_true
end
it "returns a trusted string if object is trusted" do
Marshal.dump(Object.new).untrusted?.should be_false
end
it "returns an untrusted string if object is untrusted" do
Marshal.dump(Object.new.untrust).untrusted?.should be_true
end
it "returns an untrusted string if nested object is untrusted" do
Marshal.dump([[Object.new.untrust]]).untrusted?.should be_true
end
end
end end

View file

@ -306,89 +306,6 @@ describe :marshal_load, shared: true do
end end
end end
ruby_version_is ''...'2.7' do
it "returns an untainted object if source is untainted" do
x = Object.new
y = Marshal.send(@method, Marshal.dump(x))
y.tainted?.should be_false
end
describe "when source is tainted" do
it "returns a tainted object" do
x = Object.new
x.taint
s = Marshal.dump(x)
y = Marshal.send(@method, s)
y.tainted?.should be_true
# note that round-trip via Marshal does not preserve
# the taintedness at each level of the nested structure
y = Marshal.send(@method, Marshal.dump([[x]]))
y.tainted?.should be_true
y.first.tainted?.should be_true
y.first.first.tainted?.should be_true
end
it "does not taint Symbols" do
x = [:x]
y = Marshal.send(@method, Marshal.dump(x).taint)
y.tainted?.should be_true
y.first.tainted?.should be_false
end
it "does not taint Fixnums" do
x = [1]
y = Marshal.send(@method, Marshal.dump(x).taint)
y.tainted?.should be_true
y.first.tainted?.should be_false
end
it "does not taint Bignums" do
x = [bignum_value]
y = Marshal.send(@method, Marshal.dump(x).taint)
y.tainted?.should be_true
y.first.tainted?.should be_false
end
it "does not taint Floats" do
x = [1.2]
y = Marshal.send(@method, Marshal.dump(x).taint)
y.tainted?.should be_true
y.first.tainted?.should be_false
end
end
it "preserves taintedness of nested structure" do
x = Object.new
a = [[x]]
x.taint
y = Marshal.send(@method, Marshal.dump(a))
y.tainted?.should be_true
y.first.tainted?.should be_true
y.first.first.tainted?.should be_true
end
it "returns a trusted object if source is trusted" do
x = Object.new
y = Marshal.send(@method, Marshal.dump(x))
y.untrusted?.should be_false
end
it "returns an untrusted object if source is untrusted" do
x = Object.new
x.untrust
y = Marshal.send(@method, Marshal.dump(x))
y.untrusted?.should be_true
# note that round-trip via Marshal does not preserve
# the untrustedness at each level of the nested structure
y = Marshal.send(@method, Marshal.dump([[x]]))
y.untrusted?.should be_true
y.first.untrusted?.should be_true
y.first.first.untrusted?.should be_true
end
end
# Note: Ruby 1.9 should be compatible with older marshal format # Note: Ruby 1.9 should be compatible with older marshal format
MarshalSpec::DATA.each do |description, (object, marshal, attributes)| MarshalSpec::DATA.each do |description, (object, marshal, attributes)|
it "loads a #{description}" do it "loads a #{description}" do

View file

@ -1,10 +1,8 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
describe "MatchData.allocate" do describe "MatchData.allocate" do
ruby_version_is "2.7" do
it "is undefined" do it "is undefined" do
# https://bugs.ruby-lang.org/issues/16294 # https://bugs.ruby-lang.org/issues/16294
-> { MatchData.allocate }.should raise_error(NoMethodError) -> { MatchData.allocate }.should raise_error(NoMethodError)
end end
end end
end

View file

@ -16,6 +16,12 @@ describe "MatchData#[]" do
it "supports accessors [start, length]" do it "supports accessors [start, length]" do
/(.)(.)(\d+)(\d)/.match("THX1138.")[1, 2].should == %w|H X| /(.)(.)(\d+)(\d)/.match("THX1138.")[1, 2].should == %w|H X|
/(.)(.)(\d+)(\d)/.match("THX1138.")[-3, 2].should == %w|X 113| /(.)(.)(\d+)(\d)/.match("THX1138.")[-3, 2].should == %w|X 113|
# negative index is larger than the number of match values
/(.)(.)(\d+)(\d)/.match("THX1138.")[-30, 2].should == nil
# length argument larger than number of match values is capped to match value length
/(.)(.)(\d+)(\d)/.match("THX1138.")[3, 10].should == %w|113 8|
end end
it "supports ranges [start..end]" do it "supports ranges [start..end]" do

View file

@ -7,24 +7,6 @@ describe "MatchData#post_match" do
$'.should == ': The Movie' $'.should == ': The Movie'
end end
ruby_version_is ''...'2.7' do
it "keeps taint status from the source string" do
str = "THX1138: The Movie"
str.taint
res = /(.)(.)(\d+)(\d)/.match(str).post_match
res.tainted?.should be_true
$'.tainted?.should be_true
end
it "keeps untrusted status from the source string" do
str = "THX1138: The Movie"
str.untrust
res = /(.)(.)(\d+)(\d)/.match(str).post_match
res.untrusted?.should be_true
$'.untrusted?.should be_true
end
end
it "sets the encoding to the encoding of the source String" do it "sets the encoding to the encoding of the source String" do
str = "abc".force_encoding Encoding::EUC_JP str = "abc".force_encoding Encoding::EUC_JP
str.match(/b/).post_match.encoding.should equal(Encoding::EUC_JP) str.match(/b/).post_match.encoding.should equal(Encoding::EUC_JP)

View file

@ -7,24 +7,6 @@ describe "MatchData#pre_match" do
$`.should == 'T' $`.should == 'T'
end end
ruby_version_is ''...'2.7' do
it "keeps taint status from the source string" do
str = "THX1138: The Movie"
str.taint
res = /(.)(.)(\d+)(\d)/.match(str).pre_match
res.tainted?.should be_true
$`.tainted?.should be_true
end
it "keeps untrusted status from the source string" do
str = "THX1138: The Movie"
str.untrust
res = /(.)(.)(\d+)(\d)/.match(str).pre_match
res.untrusted?.should be_true
$`.untrusted?.should be_true
end
end
it "sets the encoding to the encoding of the source String" do it "sets the encoding to the encoding of the source String" do
str = "abc".force_encoding Encoding::EUC_JP str = "abc".force_encoding Encoding::EUC_JP
str.match(/b/).pre_match.encoding.should equal(Encoding::EUC_JP) str.match(/b/).pre_match.encoding.should equal(Encoding::EUC_JP)

View file

@ -24,7 +24,6 @@ describe :method_to_s, shared: true do
@string.should =~ /\#bar/ @string.should =~ /\#bar/
end end
ruby_version_is "2.7" do
it "returns a String containing method arguments" do it "returns a String containing method arguments" do
obj = MethodSpecs::Methods.new obj = MethodSpecs::Methods.new
obj.method(:zero).send(@method).should.include?("()") obj.method(:zero).send(@method).should.include?("()")
@ -37,7 +36,6 @@ describe :method_to_s, shared: true do
obj.method(:zero_with_double_splat).send(@method).should.include?("(**a)") obj.method(:zero_with_double_splat).send(@method).should.include?("(**a)")
obj.method(:one_req_one_opt_with_splat_and_block).send(@method).should.include?("(a, b=..., *c, &blk)") obj.method(:one_req_one_opt_with_splat_and_block).send(@method).should.include?("(a, b=..., *c, &blk)")
end end
end
it "returns a String containing the Module the method is defined in" do it "returns a String containing the Module the method is defined in" do
@string.should =~ /MethodSpecs::MyMod/ @string.should =~ /MethodSpecs::MyMod/
@ -79,11 +77,9 @@ 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_version_is '2.7' do ruby_bug '#17428', ''...'3.0' do
ruby_bug '#17428', '2.7'...'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 end
end

View file

@ -47,20 +47,6 @@ describe "Module#append_features" do
end end
ruby_version_is ''...'2.7' do
it "copies own tainted status to the given module" do
other = Module.new
Module.new.taint.send :append_features, other
other.tainted?.should be_true
end
it "copies own untrusted status to the given module" do
other = Module.new
Module.new.untrust.send :append_features, other
other.untrusted?.should be_true
end
end
describe "when other is frozen" do describe "when other is frozen" do
before :each do before :each do
@receiver = Module.new @receiver = Module.new

View file

@ -18,7 +18,6 @@ describe "Module#autoload?" do
ModuleSpecs::Autoload::Child.autoload?(:AnotherAutoload).should == "another_autoload.rb" ModuleSpecs::Autoload::Child.autoload?(:AnotherAutoload).should == "another_autoload.rb"
end end
ruby_version_is "2.7" do
it "returns nil if an ancestor defined that autoload but recursion is disabled" do it "returns nil if an ancestor defined that autoload but recursion is disabled" do
ModuleSpecs::Autoload::Parent.autoload :InheritedAutoload, "inherited_autoload.rb" ModuleSpecs::Autoload::Parent.autoload :InheritedAutoload, "inherited_autoload.rb"
ModuleSpecs::Autoload::Child.autoload?(:InheritedAutoload, false).should be_nil ModuleSpecs::Autoload::Child.autoload?(:InheritedAutoload, false).should be_nil
@ -29,7 +28,6 @@ describe "Module#autoload?" do
ModuleSpecs::Autoload::Child.autoload?(:ChildAutoload, false).should == "child_autoload.rb" ModuleSpecs::Autoload::Child.autoload?(:ChildAutoload, false).should == "child_autoload.rb"
end end
end end
end
describe "Module#autoload" do describe "Module#autoload" do
before :all do before :all do
@ -514,10 +512,8 @@ describe "Module#autoload" do
it "does not load the file when accessing the constants table of the module" do it "does not load the file when accessing the constants table of the module" do
ModuleSpecs::Autoload.autoload :P, @non_existent ModuleSpecs::Autoload.autoload :P, @non_existent
ModuleSpecs::Autoload.const_defined?(:P).should be_true ModuleSpecs::Autoload.const_defined?(:P).should be_true
ruby_bug "[Bug #15780]", ""..."2.7" do
ModuleSpecs::Autoload.const_defined?("P").should be_true ModuleSpecs::Autoload.const_defined?("P").should be_true
end end
end
it "loads the file when opening a module that is the autoloaded constant" do it "loads the file when opening a module that is the autoloaded constant" do
module ModuleSpecs::Autoload::U module ModuleSpecs::Autoload::U

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