diff options
Diffstat (limited to 'spec/ruby/core/string/shared/slice.rb')
-rw-r--r-- | spec/ruby/core/string/shared/slice.rb | 128 |
1 files changed, 6 insertions, 122 deletions
diff --git a/spec/ruby/core/string/shared/slice.rb b/spec/ruby/core/string/shared/slice.rb index 1db8fd6730..228af5f824 100644 --- a/spec/ruby/core/string/shared/slice.rb +++ b/spec/ruby/core/string/shared/slice.rb @@ -80,17 +80,6 @@ describe :string_slice_index_length, shared: true do "hello there".send(@method, -3,2).should == "er" end - ruby_version_is ''...'2.7' do - it "always taints resulting strings when self is tainted" do - str = "hello world" - str.taint - - str.send(@method, 0,0).should.tainted? - str.send(@method, 0,1).should.tainted? - str.send(@method, 2,1).should.tainted? - end - end - it "returns a string with the same encoding" do s = "hello there" s.send(@method, 1, 9).encoding.should == s.encoding @@ -249,20 +238,6 @@ describe :string_slice_range, shared: true do "x".send(@method, 1...-1).should == "" end - ruby_version_is ''...'2.7' do - it "always taints resulting strings when self is tainted" do - str = "hello world" - str.taint - - str.send(@method, 0..0).should.tainted? - str.send(@method, 0...0).should.tainted? - str.send(@method, 0..1).should.tainted? - str.send(@method, 0...1).should.tainted? - str.send(@method, 2..3).should.tainted? - str.send(@method, 2..0).should.tainted? - end - end - ruby_version_is ''...'3.0' do it "returns subclass instances" do s = StringSpecs::MyString.new("hello") @@ -334,14 +309,12 @@ describe :string_slice_range, shared: true do "hello there".send(@method, eval("(-4...)")).should == "here" end - ruby_version_is "2.7" do - it "works with beginless ranges" do - "hello there".send(@method, eval("(..5)")).should == "hello " - "hello there".send(@method, eval("(...5)")).should == "hello" - "hello there".send(@method, eval("(..-4)")).should == "hello th" - "hello there".send(@method, eval("(...-4)")).should == "hello t" - "hello there".send(@method, eval("(...nil)")).should == "hello there" - end + it "works with beginless ranges" do + "hello there".send(@method, (..5)).should == "hello " + "hello there".send(@method, (...5)).should == "hello" + "hello there".send(@method, (..-4)).should == "hello th" + "hello there".send(@method, (...-4)).should == "hello t" + "hello there".send(@method, (...nil)).should == "hello there" end end @@ -356,26 +329,6 @@ describe :string_slice_regexp, shared: true do end not_supported_on :opal do - ruby_version_is ''...'2.7' do - it "always taints resulting strings when self or regexp is tainted" do - strs = ["hello world"] - strs += strs.map { |s| s.dup.taint } - - strs.each do |str| - str.send(@method, //).tainted?.should == str.tainted? - str.send(@method, /hello/).tainted?.should == str.tainted? - - tainted_re = /./ - tainted_re.taint - - str.send(@method, tainted_re).should.tainted? - end - end - - it "returns an untrusted string if the regexp is untrusted" do - "hello".send(@method, /./.untrust).untrusted?.should be_true - end - end end ruby_version_is ''...'3.0' do @@ -418,36 +371,6 @@ describe :string_slice_regexp_index, shared: true do "har".send(@method, /(.)(.)(.)/, -3).should == "h" end - ruby_version_is ''...'2.7' do - it "always taints resulting strings when self or regexp is tainted" do - strs = ["hello world"] - strs += strs.map { |s| s.dup.taint } - - strs.each do |str| - str.send(@method, //, 0).tainted?.should == str.tainted? - str.send(@method, /hello/, 0).tainted?.should == str.tainted? - - str.send(@method, /(.)(.)(.)/, 0).tainted?.should == str.tainted? - str.send(@method, /(.)(.)(.)/, 1).tainted?.should == str.tainted? - str.send(@method, /(.)(.)(.)/, -1).tainted?.should == str.tainted? - str.send(@method, /(.)(.)(.)/, -2).tainted?.should == str.tainted? - - tainted_re = /(.)(.)(.)/ - tainted_re.taint - - str.send(@method, tainted_re, 0).should.tainted? - str.send(@method, tainted_re, 1).should.tainted? - str.send(@method, tainted_re, -1).should.tainted? - end - end - - not_supported_on :opal do - it "returns an untrusted string if the regexp is untrusted" do - "hello".send(@method, /(.)/.untrust, 1).untrusted?.should be_true - end - end - end - it "returns nil if there is no match" do "hello there".send(@method, /(what?)/, 1).should == nil end @@ -510,21 +433,6 @@ describe :string_slice_string, shared: true do "hello there".send(@method, s).should == s end - ruby_version_is ''...'2.7' do - it "taints resulting strings when other is tainted" do - strs = ["", "hello world", "hello"] - strs += strs.map { |s| s.dup.taint } - - strs.each do |str| - strs.each do |other| - r = str.send(@method, other) - - r.tainted?.should == !r.nil? & other.tainted? - end - end - end - end - it "doesn't set $~" do $~ = nil @@ -584,30 +492,6 @@ describe :string_slice_regexp_group, shared: true do "hello there".send(@method, /(?<g>h(?<g>.))/, 'g').should == "e" end - ruby_version_is ''...'2.7' do - it "always taints resulting strings when self or regexp is tainted" do - strs = ["hello world"] - strs += strs.map { |s| s.dup.taint } - - strs.each do |str| - str.send(@method, /(?<hi>hello)/, 'hi').tainted?.should == str.tainted? - - str.send(@method, /(?<g>(.)(.)(.))/, 'g').tainted?.should == str.tainted? - str.send(@method, /(?<h>.)(.)(.)/, 'h').tainted?.should == str.tainted? - str.send(@method, /(.)(?<a>.)(.)/, 'a').tainted?.should == str.tainted? - str.send(@method, /(.)(.)(?<r>.)/, 'r').tainted?.should == str.tainted? - str.send(@method, /(?<h>.)(?<a>.)(?<r>.)/, 'r').tainted?.should == str.tainted? - - tainted_re = /(?<a>.)(?<b>.)(?<c>.)/ - tainted_re.taint - - str.send(@method, tainted_re, 'a').tainted?.should be_true - str.send(@method, tainted_re, 'b').tainted?.should be_true - str.send(@method, tainted_re, 'c').tainted?.should be_true - end - end - end - it "returns nil if there is no match" do "hello there".send(@method, /(?<whut>what?)/, 'whut').should be_nil end |