diff options
author | Benoit Daloze <eregontp@gmail.com> | 2021-06-02 14:34:07 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2021-06-02 14:34:07 +0200 |
commit | 22e2a6a999b958efe5d84d9c7314e450fda82254 (patch) | |
tree | b2dc946cf2fe2c250d0583675e548c67dca3e71a /spec/ruby/core/hash | |
parent | a4fbc7e2884ba694278adea3b32ddb8c2ac10efe (diff) | |
download | ruby-22e2a6a999b958efe5d84d9c7314e450fda82254.tar.gz |
Update to ruby/spec@a0b7d0d
Diffstat (limited to 'spec/ruby/core/hash')
-rw-r--r-- | spec/ruby/core/hash/rehash_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/ruby/core/hash/rehash_spec.rb b/spec/ruby/core/hash/rehash_spec.rb index ff7b644786..0049080456 100644 --- a/spec/ruby/core/hash/rehash_spec.rb +++ b/spec/ruby/core/hash/rehash_spec.rb @@ -59,6 +59,24 @@ describe "Hash#rehash" do h.keys.should == [a] end + it "removes duplicate keys for large hashes" do + a = [1,2] + b = [1] + + h = {} + h[a] = true + h[b] = true + 100.times { |n| h[n] = true } + b << 2 + h.size.should == 102 + h.keys.should.include? a + h.keys.should.include? b + h.rehash + h.size.should == 101 + h.keys.should.include? a + h.keys.should_not.include? [1] + end + it "raises a FrozenError if called on a frozen instance" do -> { HashSpecs.frozen_hash.rehash }.should raise_error(FrozenError) -> { HashSpecs.empty_frozen_hash.rehash }.should raise_error(FrozenError) |