Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions core/set/classify_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,19 @@
classified.should == { 3 => Set["one", "two"], 4 => Set["four"], 5 => Set["three"] }
end

it "does not retain compare_by_identity flag" do
set = Set["one", "two"].compare_by_identity
classified = set.classify { |x| x.length }
classified.values.each { |s| s.compare_by_identity?.should == false }
ruby_version_is "4.1" do
it "retains compare_by_identity flag" do
set = Set["one", "two"].compare_by_identity
classified = set.classify { |x| x.length }
classified.values.each { |s| s.compare_by_identity?.should == true }
end
end

ruby_version_is ""..."4.0" do
it "does not retain compare_by_identity flag" do
set = Set["one", "two"].compare_by_identity
classified = set.classify { |x| x.length }
classified.values.each { |s| s.compare_by_identity?.should == false }
end
end
end
18 changes: 14 additions & 4 deletions core/set/divide_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,20 @@
ret.each(&:even?).should == Set[Set[1, 3], Set[2, 4]]
end

it "does not retain compare_by_identity flag" do
set = Set["one", "two"].compare_by_identity
res = set.divide { |x| x.length }
res.each { |s| s.compare_by_identity?.should == false }
ruby_version_is "4.1" do
it "retains compare_by_identity flag" do
set = Set["one", "two"].compare_by_identity
res = set.divide { |x| x.length }
res.each { |s| s.compare_by_identity?.should == true }
end
end

ruby_version_is ""..."4.0" do
it "does not retain compare_by_identity flag" do
set = Set["one", "two"].compare_by_identity
res = set.divide { |x| x.length }
res.each { |s| s.compare_by_identity?.should == false }
end
end
end

Expand Down
33 changes: 25 additions & 8 deletions core/set/flatten_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@
-> { set.flatten }.should.raise(ArgumentError)
end

ruby_version_is "4.1" do
it "retains compare_by_identity flag" do
set = Set[1, 2, Set[3, 4]].compare_by_identity
set.flatten.compare_by_identity?.should == true
end
end

ruby_version_is ""..."4.0" 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

it "does not retain compare_by_identity flag" do
set = Set[1, 2, Set[3, 4]].compare_by_identity
set.flatten.compare_by_identity?.should == false
it "does not retain compare_by_identity flag" do
set = Set[1, 2, Set[3, 4]].compare_by_identity
set.flatten.compare_by_identity?.should == false
end
end
end

Expand All @@ -52,10 +59,20 @@
-> { set.flatten! }.should.raise(ArgumentError)
end

it "does not retain compare_by_identity flag when flattening elements" do
set = Set[1, 2, Set[3, 4]].compare_by_identity
set.flatten!
set.compare_by_identity?.should == false
ruby_version_is "4.1" do
it "retains compare_by_identity flag when flattening elements" do
set = Set[1, 2, Set[3, 4]].compare_by_identity
set.flatten!
set.compare_by_identity?.should == true
end
end

ruby_version_is ""..."4.0" do
it "does not retain compare_by_identity flag when flattening elements" do
set = Set[1, 2, Set[3, 4]].compare_by_identity
set.flatten!
set.compare_by_identity?.should == false
end
end

it "retains compare_by_identity flag if no elements are flattened" do
Expand Down
18 changes: 14 additions & 4 deletions core/set/intersection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@
-> { @set & Object.new }.should.raise(ArgumentError)
end

it "does not retain compare_by_identity flag" do
@set.compare_by_identity
(@set & Set[:b, :c, :d, :e]).compare_by_identity?.should == false
(@set & [:b, :c, :d]).compare_by_identity?.should == false
ruby_version_is "4.1" do
it "retains compare_by_identity flag" do
@set.compare_by_identity
(@set & Set[:b, :c, :d, :e]).compare_by_identity?.should == true
(@set & [:b, :c, :d]).compare_by_identity?.should == true
end
end

ruby_version_is ""..."4.0" do
it "does not retain compare_by_identity flag" do
@set.compare_by_identity
(@set & Set[:b, :c, :d, :e]).compare_by_identity?.should == false
(@set & [:b, :c, :d]).compare_by_identity?.should == false
end
end
end
18 changes: 14 additions & 4 deletions core/set/map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@
@set.should == Set[2, 4, 6, 8, 10]
end

it "does not retain compare_by_identity flag" do
@set.compare_by_identity
@set.map! { |x| x * 2 }
@set.compare_by_identity?.should == false
ruby_version_is "4.1" do
it "retains compare_by_identity flag" do
@set.compare_by_identity
@set.map! { |x| x * 2 }
@set.compare_by_identity?.should == true
end
end

ruby_version_is ""..."4.0" do
it "does not retain compare_by_identity flag" do
@set.compare_by_identity
@set.map! { |x| x * 2 }
@set.compare_by_identity?.should == false
end
end
end
Loading