Permalink
Browse files

Specs for Hash when key has private hash method

  • Loading branch information...
1 parent baef812 commit 4822048cdabc4af91b8ab60f2a43033efbc1a979 @brainopia brainopia committed Feb 24, 2013
@@ -20,6 +20,11 @@
new_hash { :defualt }.delete(:d).should == nil
end
+ it "accepts keys with private #hash method" do
+ key = HashSpecs::KeyWithPrivateHash.new
+ new_hash(key => 5).delete(key).should == 5
+ end
+
ruby_version_is "" ... "1.9" do
it "raises a TypeError if called on a frozen instance" do
lambda { HashSpecs.frozen_hash.delete("foo") }.should raise_error(TypeError)
@@ -112,4 +112,9 @@
new_hash(x => :x)[x].should == :x
end
+
+ it "supports keys with private #hash method" do
+ key = HashSpecs::KeyWithPrivateHash.new
+ new_hash(key => 42)[key].should == 42
+ end
end
@@ -29,6 +29,10 @@ def to_hash
end
end
+ class KeyWithPrivateHash
+ private :hash
+ end
+
def self.empty_frozen_hash
@empty ||= new_hash
@empty.freeze
@@ -27,6 +27,13 @@ def key.reverse() "bar" end
h.size.should == 2
end
+ it "accepts keys with private #hash method" do
+ key = HashSpecs::KeyWithPrivateHash.new
+ h = new_hash
+ h[key] = "foo"
+ h[key].should == "foo"
+ end
+
it "duplicates and freezes string keys" do
key = "foo"
h = new_hash

0 comments on commit 4822048

Please sign in to comment.