summaryrefslogtreecommitdiff
path: root/spec/ruby/core/enumerable
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/enumerable
parentc5c05460ac20abcbc0ed686eb4acf06da7a39a79 (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2476
Diffstat (limited to 'spec/ruby/core/enumerable')
-rw-r--r--spec/ruby/core/enumerable/group_by_spec.rb14
-rw-r--r--spec/ruby/core/enumerable/shared/entries.rb12
-rw-r--r--spec/ruby/core/enumerable/uniq_spec.rb90
3 files changed, 76 insertions, 40 deletions
diff --git a/spec/ruby/core/enumerable/group_by_spec.rb b/spec/ruby/core/enumerable/group_by_spec.rb
index 580a90cf0c..52b5a68d64 100644
--- a/spec/ruby/core/enumerable/group_by_spec.rb
+++ b/spec/ruby/core/enumerable/group_by_spec.rb
@@ -33,12 +33,14 @@ describe "Enumerable#group_by" do
[3, 4, 5] => [[3, 4, 5]] }
end
- 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
+ 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
diff --git a/spec/ruby/core/enumerable/shared/entries.rb b/spec/ruby/core/enumerable/shared/entries.rb
index f52844cb45..590ce73bcf 100644
--- a/spec/ruby/core/enumerable/shared/entries.rb
+++ b/spec/ruby/core/enumerable/shared/entries.rb
@@ -14,11 +14,13 @@ describe :enumerable_entries, shared: true do
count.arguments_passed.should == [:hello, "world"]
end
- it "returns a tainted array if self is tainted" do
- EnumerableSpecs::Empty.new.taint.send(@method).tainted?.should be_true
- 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
+ it "returns an untrusted array if self is untrusted" do
+ EnumerableSpecs::Empty.new.untrust.send(@method).untrusted?.should be_true
+ end
end
end
diff --git a/spec/ruby/core/enumerable/uniq_spec.rb b/spec/ruby/core/enumerable/uniq_spec.rb
index c286882e92..82c041d4ef 100644
--- a/spec/ruby/core/enumerable/uniq_spec.rb
+++ b/spec/ruby/core/enumerable/uniq_spec.rb
@@ -31,44 +31,76 @@ describe 'Enumerable#uniq' do
[x, y].to_enum.uniq.should == [x, y]
end
- 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
+ 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)
+ false
+ end
+
+ obj
end
- obj
- end
+ a.uniq.should == a
- a.uniq.should == a
- a[0].tainted?.should == true
- a[1].tainted?.should == true
+ a = Array.new(2) do
+ obj = mock('0')
+ obj.should_receive(:hash).at_least(1).and_return(0)
- a = Array.new(2) do
- obj = mock('0')
- obj.should_receive(:hash).at_least(1).and_return(0)
+ def obj.eql?(o)
+ true
+ end
- 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
+ obj
end
- obj
+ a.to_enum.uniq.size.should == 1
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].tainted?.should == true
+ a[1].tainted?.should == 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].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].tainted?.should == true
- a[1].tainted?.should == true
+ a.to_enum.uniq.size.should == 1
+ a[0].tainted?.should == true
+ a[1].tainted?.should == true
+ end
end
context 'when yielded with multiple arguments' do