diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-07-31 11:04:35 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-07-31 11:04:35 +0200 |
commit | eab6c534adb381b81291e871cd57c957cf786503 (patch) | |
tree | 77c4f00e6de6b466c06c1f3ff2327a9bf62288fe /spec/ruby | |
parent | 14eede6e530f58bc22fb6d89ecf910eb1cfcf240 (diff) | |
download | ruby-eab6c534adb381b81291e871cd57c957cf786503.tar.gz |
Attempt to fix Hash#rehash spec
Diffstat (limited to 'spec/ruby')
-rw-r--r-- | spec/ruby/core/hash/rehash_spec.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/spec/ruby/core/hash/rehash_spec.rb b/spec/ruby/core/hash/rehash_spec.rb index 2af287cd70..1bf4753f4e 100644 --- a/spec/ruby/core/hash/rehash_spec.rb +++ b/spec/ruby/core/hash/rehash_spec.rb @@ -3,23 +3,26 @@ require_relative 'fixtures/classes' describe "Hash#rehash" do it "reorganizes the hash by recomputing all key hash codes" do - k1 = [1] - k2 = [2] + k1 = Object.new + k2 = Object.new + def k1.hash; 0; end + def k2.hash; 1; end + h = {} - h[k1] = 0 - h[k2] = 1 + h[k1] = :v1 + h[k2] = :v2 - k1 << 2 + def k1.hash; 1; end - # if k1 is modified to k1', k1.hash and k1'.hash can be same. - # So this test has an issue. For the present, this line is commented out. - # h.key?(k1).should == false + # The key should no longer be found as the #hash changed. + # Hash values 0 and 1 should not conflict, even with 1-bit stored hash. + h.key?(k1).should == false h.keys.include?(k1).should == true h.rehash.should equal(h) h.key?(k1).should == true - h[k1].should == 0 + h[k1].should == :v1 k1 = mock('k1') k2 = mock('k2') |