Attempt to fix Hash#rehash spec
This commit is contained in:
parent
14eede6e53
commit
eab6c534ad
@ -3,23 +3,26 @@ require_relative 'fixtures/classes'
|
|||||||
|
|
||||||
describe "Hash#rehash" do
|
describe "Hash#rehash" do
|
||||||
it "reorganizes the hash by recomputing all key hash codes" do
|
it "reorganizes the hash by recomputing all key hash codes" do
|
||||||
k1 = [1]
|
k1 = Object.new
|
||||||
k2 = [2]
|
k2 = Object.new
|
||||||
|
def k1.hash; 0; end
|
||||||
|
def k2.hash; 1; end
|
||||||
|
|
||||||
h = {}
|
h = {}
|
||||||
h[k1] = 0
|
h[k1] = :v1
|
||||||
h[k2] = 1
|
h[k2] = :v2
|
||||||
|
|
||||||
k1 << 2
|
def k1.hash; 1; end
|
||||||
|
|
||||||
# if k1 is modified to k1', k1.hash and k1'.hash can be same.
|
# The key should no longer be found as the #hash changed.
|
||||||
# So this test has an issue. For the present, this line is commented out.
|
# Hash values 0 and 1 should not conflict, even with 1-bit stored hash.
|
||||||
# h.key?(k1).should == false
|
h.key?(k1).should == false
|
||||||
|
|
||||||
h.keys.include?(k1).should == true
|
h.keys.include?(k1).should == true
|
||||||
|
|
||||||
h.rehash.should equal(h)
|
h.rehash.should equal(h)
|
||||||
h.key?(k1).should == true
|
h.key?(k1).should == true
|
||||||
h[k1].should == 0
|
h[k1].should == :v1
|
||||||
|
|
||||||
k1 = mock('k1')
|
k1 = mock('k1')
|
||||||
k2 = mock('k2')
|
k2 = mock('k2')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user