aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/array/shared
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-24 20:59:12 -0700
committerJeremy Evans <code@jeremyevans.net>2019-11-18 01:00:25 +0200
commitffd0820ab317542f8780aac475da590a4bdbc7a8 (patch)
tree6a5d774933c15fd2b9ea948bd3ae2fa587faaf82 /spec/ruby/core/array/shared
parentc5c05460ac20abcbc0ed686eb4acf06da7a39a79 (diff)
downloadruby-ffd0820ab317542f8780aac475da590a4bdbc7a8.tar.gz
Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
Diffstat (limited to 'spec/ruby/core/array/shared')
-rw-r--r--spec/ruby/core/array/shared/clone.rb36
-rw-r--r--spec/ruby/core/array/shared/collect.rb46
-rw-r--r--spec/ruby/core/array/shared/inspect.rb36
-rw-r--r--spec/ruby/core/array/shared/join.rb96
4 files changed, 113 insertions, 101 deletions
diff --git a/spec/ruby/core/array/shared/clone.rb b/spec/ruby/core/array/shared/clone.rb
index 95d0d0a3d5..f6f581b17c 100644
--- a/spec/ruby/core/array/shared/clone.rb
+++ b/spec/ruby/core/array/shared/clone.rb
@@ -18,25 +18,27 @@ describe :array_clone, shared: true do
b.__id__.should_not == a.__id__
end
- 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
+ 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.tainted?.should == true
- bb.tainted?.should == false
- end
+ aa.tainted?.should == true
+ bb.tainted?.should == false
+ 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
+ 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.untrusted?.should == true
- bb.untrusted?.should == false
+ aa.untrusted?.should == true
+ bb.untrusted?.should == false
+ end
end
end
diff --git a/spec/ruby/core/array/shared/collect.rb b/spec/ruby/core/array/shared/collect.rb
index 80e2739893..cbe32d2ab4 100644
--- a/spec/ruby/core/array/shared/collect.rb
+++ b/spec/ruby/core/array/shared/collect.rb
@@ -42,16 +42,18 @@ describe :array_collect, shared: true do
}.should raise_error(ArgumentError)
end
- it "does not copy tainted status" do
- a = [1, 2, 3]
- a.taint
- a.send(@method){|x| x}.tainted?.should be_false
- 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
+ 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
@@ -94,19 +96,21 @@ describe :array_collect_b, shared: true do
a.should == ["1!", "2!", "3!"]
end
- 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
+ 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
+ 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
diff --git a/spec/ruby/core/array/shared/inspect.rb b/spec/ruby/core/array/shared/inspect.rb
index 434440c25b..736f8d946b 100644
--- a/spec/ruby/core/array/shared/inspect.rb
+++ b/spec/ruby/core/array/shared/inspect.rb
@@ -64,28 +64,30 @@ describe :array_inspect, shared: true do
ArraySpecs.empty_recursive_array.send(@method).should == "[[...]]"
end
- it "taints the result if the Array is non-empty and tainted" do
- [1, 2].taint.send(@method).tainted?.should be_true
- 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 "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 "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 "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 "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
+ it "untrusts the result if an element is untrusted" do
+ ["str".untrust].send(@method).untrusted?.should be_true
+ end
end
describe "with encoding" do
diff --git a/spec/ruby/core/array/shared/join.rb b/spec/ruby/core/array/shared/join.rb
index 38bdde9502..5e7193de8a 100644
--- a/spec/ruby/core/array/shared/join.rb
+++ b/spec/ruby/core/array/shared/join.rb
@@ -58,32 +58,34 @@ describe :array_join_with_default_separator, shared: true do
-> { ArraySpecs.empty_recursive_array.send(@method) }.should raise_error(ArgumentError)
end
- it "taints the result if the Array is tainted and non-empty" do
- [1, 2].taint.send(@method).tainted?.should be_true
- 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 "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 "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 "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 "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
+ 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
@@ -125,39 +127,41 @@ describe :array_join_with_string_separator, shared: true do
[1, [2, ArraySpecs::MyArray[3, 4], 5], 6].send(@method, ":").should == "1:2:3:4:5:6"
end
- describe "with a tainted separator" do
- before :each do
- @sep = ":".taint
- 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 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 "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
+ it "taints the result if the array has two or more elements" do
+ [1, 2].send(@method, @sep).tainted?.should be_true
+ end
end
- end
- describe "with an untrusted separator" do
- before :each do
- @sep = ":".untrust
- 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 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 "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
+ 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