Created
January 22, 2014 17:31
-
-
Save gwik/8563158 to your computer and use it in GitHub Desktop.
Spec demonstrating broken weakref as hash key in rubymotion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "WeakRef hash support" do | |
before do | |
@k = "key" | |
@w = WeakRef.new(@k) | |
@h = {@w => :value} | |
end | |
it "can be accessed with the original object" do | |
@h[@k].should == :value | |
end | |
it "can be accessed with the equal string" do | |
@h["key"].should == :value | |
end | |
it "can be accessed with an other weakref to the same string" do | |
k2 = "key" | |
w2 = WeakRef.new(k2) | |
@h[w2].should == :value | |
end | |
it "can be accessed with the weakref" do | |
@h[@w].should == :value | |
end | |
it "string is eql? to weakref" do | |
@k.should.eql?(@w) | |
end | |
it "weakref is eql? to string" do | |
@w.should.eql?(@k) | |
end | |
it "has the same hash" do | |
@k.hash.should == @w.hash | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment