summaryrefslogtreecommitdiff
path: root/spec/ruby/library
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library')
-rw-r--r--spec/ruby/library/set/compare_by_identity_spec.rb21
-rw-r--r--spec/ruby/library/set/divide_spec.rb18
-rw-r--r--spec/ruby/library/set/equal_value_spec.rb8
-rw-r--r--spec/ruby/library/set/flatten_merge_spec.rb28
-rw-r--r--spec/ruby/library/set/flatten_spec.rb16
-rw-r--r--spec/ruby/library/set/hash_spec.rb8
-rw-r--r--spec/ruby/library/set/join_spec.rb10
-rw-r--r--spec/ruby/library/set/proper_subset_spec.rb8
-rw-r--r--spec/ruby/library/set/proper_superset_spec.rb8
-rw-r--r--spec/ruby/library/set/subset_spec.rb8
-rw-r--r--spec/ruby/library/set/superset_spec.rb8
11 files changed, 91 insertions, 50 deletions
diff --git a/spec/ruby/library/set/compare_by_identity_spec.rb b/spec/ruby/library/set/compare_by_identity_spec.rb
index 602d1e758e..ad90cd8a8e 100644
--- a/spec/ruby/library/set/compare_by_identity_spec.rb
+++ b/spec/ruby/library/set/compare_by_identity_spec.rb
@@ -91,11 +91,22 @@ describe "Set#compare_by_identity" do
set.to_a.sort.should == [a1, a2].sort
end
- it "raises a FrozenError on frozen sets" do
- set = Set.new.freeze
- -> {
- set.compare_by_identity
- }.should raise_error(FrozenError, /frozen Hash/)
+ ruby_version_is "3.5" do
+ it "raises a FrozenError on frozen sets" do
+ set = Set.new.freeze
+ -> {
+ set.compare_by_identity
+ }.should raise_error(FrozenError, "can't modify frozen Set: #<Set: {}>")
+ end
+ end
+
+ ruby_version_is ""..."3.5" do
+ it "raises a FrozenError on frozen sets" do
+ set = Set.new.freeze
+ -> {
+ set.compare_by_identity
+ }.should raise_error(FrozenError, /frozen Hash/)
+ end
end
it "persists over #dups" do
diff --git a/spec/ruby/library/set/divide_spec.rb b/spec/ruby/library/set/divide_spec.rb
index 998a1b292c..314d9942eb 100644
--- a/spec/ruby/library/set/divide_spec.rb
+++ b/spec/ruby/library/set/divide_spec.rb
@@ -26,10 +26,20 @@ describe "Set#divide when passed a block with an arity of 2" do
set.map{ |x| x.to_a.sort }.sort.should == [[1], [3, 4], [6], [9, 10, 11]]
end
- it "yields each two Object to the block" do
- ret = []
- Set[1, 2].divide { |x, y| ret << [x, y] }
- ret.sort.should == [[1, 1], [1, 2], [2, 1], [2, 2]]
+ ruby_version_is "3.5" do
+ it "yields each two Object to the block" do
+ ret = []
+ Set[1, 2].divide { |x, y| ret << [x, y] }
+ ret.sort.should == [[1, 2], [2, 1]]
+ end
+ end
+
+ ruby_version_is ""..."3.5" do
+ it "yields each two Object to the block" do
+ ret = []
+ Set[1, 2].divide { |x, y| ret << [x, y] }
+ ret.sort.should == [[1, 1], [1, 2], [2, 1], [2, 2]]
+ end
end
it "returns an enumerator when not passed a block" do
diff --git a/spec/ruby/library/set/equal_value_spec.rb b/spec/ruby/library/set/equal_value_spec.rb
index f5b5f790c0..cac4a99fd5 100644
--- a/spec/ruby/library/set/equal_value_spec.rb
+++ b/spec/ruby/library/set/equal_value_spec.rb
@@ -25,9 +25,11 @@ describe "Set#==" do
set1.should == set2
end
- context "when comparing to a Set-like object" do
- it "returns true when a Set and a Set-like object contain the same elements" do
- Set[1, 2, 3].should == SetSpecs::SetLike.new([1, 2, 3])
+ ruby_version_is ""..."3.5" do
+ context "when comparing to a Set-like object" do
+ it "returns true when a Set and a Set-like object contain the same elements" do
+ Set[1, 2, 3].should == SetSpecs::SetLike.new([1, 2, 3])
+ end
end
end
end
diff --git a/spec/ruby/library/set/flatten_merge_spec.rb b/spec/ruby/library/set/flatten_merge_spec.rb
index f2c99a9481..a0883ebc9d 100644
--- a/spec/ruby/library/set/flatten_merge_spec.rb
+++ b/spec/ruby/library/set/flatten_merge_spec.rb
@@ -2,22 +2,24 @@ require_relative '../../spec_helper'
require 'set'
describe "Set#flatten_merge" do
- it "is protected" do
- Set.should have_protected_instance_method("flatten_merge")
- end
+ ruby_version_is ""..."3.5" do
+ it "is protected" do
+ Set.should have_protected_instance_method("flatten_merge")
+ end
- it "flattens the passed Set and merges it into self" do
- set1 = Set[1, 2]
- set2 = Set[3, 4, Set[5, 6]]
+ it "flattens the passed Set and merges it into self" do
+ set1 = Set[1, 2]
+ set2 = Set[3, 4, Set[5, 6]]
- set1.send(:flatten_merge, set2).should == Set[1, 2, 3, 4, 5, 6]
- end
+ set1.send(:flatten_merge, set2).should == Set[1, 2, 3, 4, 5, 6]
+ end
- it "raises an ArgumentError when trying to flatten a recursive Set" do
- set1 = Set[1, 2, 3]
- set2 = Set[5, 6, 7]
- set2 << set2
+ it "raises an ArgumentError when trying to flatten a recursive Set" do
+ set1 = Set[1, 2, 3]
+ set2 = Set[5, 6, 7]
+ set2 << set2
- -> { set1.send(:flatten_merge, set2) }.should raise_error(ArgumentError)
+ -> { set1.send(:flatten_merge, set2) }.should raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/ruby/library/set/flatten_spec.rb b/spec/ruby/library/set/flatten_spec.rb
index 51b58d6439..c075225181 100644
--- a/spec/ruby/library/set/flatten_spec.rb
+++ b/spec/ruby/library/set/flatten_spec.rb
@@ -17,9 +17,11 @@ describe "Set#flatten" do
-> { set.flatten }.should raise_error(ArgumentError)
end
- context "when Set contains a Set-like object" do
- it "returns a copy of self with each included Set-like object flattened" do
- Set[SetSpecs::SetLike.new([1])].flatten.should == Set[1]
+ ruby_version_is ""..."3.5" do
+ context "when Set contains a Set-like object" do
+ it "returns a copy of self with each included Set-like object flattened" do
+ Set[SetSpecs::SetLike.new([1])].flatten.should == Set[1]
+ end
end
end
end
@@ -47,9 +49,11 @@ describe "Set#flatten!" do
end
version_is(set_version, ""..."1.1.0") do #ruby_version_is ""..."3.3" do
- context "when Set contains a Set-like object" do
- it "flattens self, including Set-like objects" do
- Set[SetSpecs::SetLike.new([1])].flatten!.should == Set[1]
+ ruby_version_is ""..."3.5" do
+ context "when Set contains a Set-like object" do
+ it "flattens self, including Set-like objects" do
+ Set[SetSpecs::SetLike.new([1])].flatten!.should == Set[1]
+ end
end
end
end
diff --git a/spec/ruby/library/set/hash_spec.rb b/spec/ruby/library/set/hash_spec.rb
index c5bab73931..9be487a2b1 100644
--- a/spec/ruby/library/set/hash_spec.rb
+++ b/spec/ruby/library/set/hash_spec.rb
@@ -11,8 +11,10 @@ describe "Set#hash" do
Set[1, 2, 3].hash.should_not == Set[:a, "b", ?c].hash
end
- # see https://github.com/jruby/jruby/issues/8393
- it "is equal to nil.hash for an uninitialized Set" do
- Set.allocate.hash.should == nil.hash
+ ruby_version_is ""..."3.5" do
+ # see https://github.com/jruby/jruby/issues/8393
+ it "is equal to nil.hash for an uninitialized Set" do
+ Set.allocate.hash.should == nil.hash
+ end
end
end
diff --git a/spec/ruby/library/set/join_spec.rb b/spec/ruby/library/set/join_spec.rb
index 3f511a84e4..a37f35947a 100644
--- a/spec/ruby/library/set/join_spec.rb
+++ b/spec/ruby/library/set/join_spec.rb
@@ -21,9 +21,11 @@ describe "Set#join" do
set.join(' | ').should == "a | b | c"
end
- it "calls #to_a to convert the Set in to an Array" do
- set = Set[:a, :b, :c]
- set.should_receive(:to_a).and_return([:a, :b, :c])
- set.join.should == "abc"
+ ruby_version_is ""..."3.5" do
+ it "calls #to_a to convert the Set in to an Array" do
+ set = Set[:a, :b, :c]
+ set.should_receive(:to_a).and_return([:a, :b, :c])
+ set.join.should == "abc"
+ end
end
end
diff --git a/spec/ruby/library/set/proper_subset_spec.rb b/spec/ruby/library/set/proper_subset_spec.rb
index 6b51dedc9f..e58b23f5ff 100644
--- a/spec/ruby/library/set/proper_subset_spec.rb
+++ b/spec/ruby/library/set/proper_subset_spec.rb
@@ -35,9 +35,11 @@ describe "Set#proper_subset?" do
end
version_is(set_version, ""..."1.1.0") do #ruby_version_is ""..."3.3" do
- context "when comparing to a Set-like object" do
- it "returns true if passed a Set-like object that self is a proper subset of" do
- Set[1, 2, 3].proper_subset?(SetSpecs::SetLike.new([1, 2, 3, 4])).should be_true
+ ruby_version_is ""..."3.5" do
+ context "when comparing to a Set-like object" do
+ it "returns true if passed a Set-like object that self is a proper subset of" do
+ Set[1, 2, 3].proper_subset?(SetSpecs::SetLike.new([1, 2, 3, 4])).should be_true
+ end
end
end
end
diff --git a/spec/ruby/library/set/proper_superset_spec.rb b/spec/ruby/library/set/proper_superset_spec.rb
index a386c8c097..fbd94fb75d 100644
--- a/spec/ruby/library/set/proper_superset_spec.rb
+++ b/spec/ruby/library/set/proper_superset_spec.rb
@@ -33,9 +33,11 @@ describe "Set#proper_superset?" do
-> { Set[].proper_superset?(Object.new) }.should raise_error(ArgumentError)
end
- context "when comparing to a Set-like object" do
- it "returns true if passed a Set-like object that self is a proper superset of" do
- Set[1, 2, 3, 4].proper_superset?(SetSpecs::SetLike.new([1, 2, 3])).should be_true
+ ruby_version_is ""..."3.5" do
+ context "when comparing to a Set-like object" do
+ it "returns true if passed a Set-like object that self is a proper superset of" do
+ Set[1, 2, 3, 4].proper_superset?(SetSpecs::SetLike.new([1, 2, 3])).should be_true
+ end
end
end
end
diff --git a/spec/ruby/library/set/subset_spec.rb b/spec/ruby/library/set/subset_spec.rb
index 85666d633f..0494aa25cb 100644
--- a/spec/ruby/library/set/subset_spec.rb
+++ b/spec/ruby/library/set/subset_spec.rb
@@ -35,9 +35,11 @@ describe "Set#subset?" do
end
version_is(set_version, ""..."1.1.0") do #ruby_version_is ""..."3.3" do
- context "when comparing to a Set-like object" do
- it "returns true if passed a Set-like object that self is a subset of" do
- Set[1, 2, 3].subset?(SetSpecs::SetLike.new([1, 2, 3, 4])).should be_true
+ ruby_version_is ""..."3.5" do
+ context "when comparing to a Set-like object" do
+ it "returns true if passed a Set-like object that self is a subset of" do
+ Set[1, 2, 3].subset?(SetSpecs::SetLike.new([1, 2, 3, 4])).should be_true
+ end
end
end
end
diff --git a/spec/ruby/library/set/superset_spec.rb b/spec/ruby/library/set/superset_spec.rb
index bd9d2f3eee..46fdc358e4 100644
--- a/spec/ruby/library/set/superset_spec.rb
+++ b/spec/ruby/library/set/superset_spec.rb
@@ -33,9 +33,11 @@ describe "Set#superset?" do
-> { Set[].superset?(Object.new) }.should raise_error(ArgumentError)
end
- context "when comparing to a Set-like object" do
- it "returns true if passed a Set-like object that self is a superset of" do
- Set[1, 2, 3, 4].superset?(SetSpecs::SetLike.new([1, 2, 3])).should be_true
+ ruby_version_is ""..."3.5" do
+ context "when comparing to a Set-like object" do
+ it "returns true if passed a Set-like object that self is a superset of" do
+ Set[1, 2, 3, 4].superset?(SetSpecs::SetLike.new([1, 2, 3])).should be_true
+ end
end
end
end