Skip to content

Commit

Permalink
Add spec for compare_by_identity in Hash#replace
Browse files Browse the repository at this point in the history
  • Loading branch information
herwinw committed Jun 16, 2024
1 parent 94d8b4b commit 5bdb1cd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions core/hash/replace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@
h.should == { 1 => 2 }
end

it "transfers the compare_by_identity flag" do
hash_a = { a: 1 }
hash_b = { b: 2 }
hash_b.compare_by_identity
hash_a.should_not.compare_by_identity?
hash_a.replace(hash_b)
hash_a.should.compare_by_identity?

hash_a = { a: 1 }
hash_b = { b: 2 }
hash_a.compare_by_identity
hash_a.should.compare_by_identity?
hash_a.replace(hash_b)
hash_a.should_not.compare_by_identity?
end

it "does not transfer default values" do
hash_a = {}
hash_b = Hash.new(5)
Expand Down

0 comments on commit 5bdb1cd

Please sign in to comment.