summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/split_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/split_spec.rb')
-rw-r--r--spec/ruby/core/string/split_spec.rb71
1 files changed, 10 insertions, 61 deletions
diff --git a/spec/ruby/core/string/split_spec.rb b/spec/ruby/core/string/split_spec.rb
index 2da71948b3..82911ef50b 100644
--- a/spec/ruby/core/string/split_spec.rb
+++ b/spec/ruby/core/string/split_spec.rb
@@ -89,21 +89,19 @@ describe "String#split with String" do
end
end
- ruby_version_is "2.7" do
- context "when $; is not nil" do
- before do
- suppress_warning do
- @old_value, $; = $;, 'foobar'
- end
+ context "when $; is not nil" do
+ before do
+ suppress_warning do
+ @old_value, $; = $;, 'foobar'
end
+ end
- after do
- $; = @old_value
- end
+ after do
+ $; = @old_value
+ end
- it "warns" do
- -> { "".split }.should complain(/warning: \$; is set to non-nil value/)
- end
+ it "warns" do
+ -> { "".split }.should complain(/warning: \$; is set to non-nil value/)
end
end
end
@@ -207,24 +205,6 @@ describe "String#split with String" do
end
end
- ruby_version_is ''...'2.7' do
- it "taints the resulting strings if self is tainted" do
- ["", "x.y.z.", " x y "].each do |str|
- ["", ".", " "].each do |pat|
- [-1, 0, 1, 2].each do |limit|
- str.dup.taint.split(pat).each do |x|
- x.should.tainted?
- end
-
- str.split(pat.dup.taint).each do |x|
- x.should_not.tainted?
- end
- end
- end
- end
- end
- end
-
it "returns an empty array when whitespace is split on whitespace" do
" ".split(" ").should == []
" \n ".split(" ").should == []
@@ -426,37 +406,6 @@ describe "String#split with Regexp" do
end
end
- ruby_version_is ''...'2.7' do
- it "taints the resulting strings if self is tainted" do
- ["", "x:y:z:", " x y "].each do |str|
- [//, /:/, /\s+/].each do |pat|
- [-1, 0, 1, 2].each do |limit|
- str.dup.taint.split(pat, limit).each do |x|
- # See the spec below for why the conditional is here
- x.tainted?.should be_true unless x.empty?
- end
- end
- end
- end
- end
-
- it "taints an empty string if self is tainted" do
- ":".taint.split(//, -1).last.tainted?.should be_true
- end
-
- it "doesn't taints the resulting strings if the Regexp is tainted" do
- ["", "x:y:z:", " x y "].each do |str|
- [//, /:/, /\s+/].each do |pat|
- [-1, 0, 1, 2].each do |limit|
- str.split(pat.dup.taint, limit).each do |x|
- x.tainted?.should be_false
- end
- end
- end
- end
- end
- end
-
it "retains the encoding of the source string" do
ary = "а б в".split
encodings = ary.map { |s| s.encoding }