Skip to content
Permalink
Browse files

more passing specs for hashes + enumerators

  • Loading branch information
Alex Gaynor
Alex Gaynor committed Apr 7, 2013
1 parent fc9f012 commit a5496561a9d8fcec9c0f96ba6f52e39d4b705b69
@@ -1,5 +1,6 @@
class Hash
def each
def each(&block)
return self.enum_for(:each) if !block
iter = Topaz::HashIterator.new(self)
while true
begin
@@ -12,10 +13,16 @@ def each
end
alias each_pair each

def each_key
def each_key(&block)
return self.enum_for(:each_key) if !block
each { |k, v| yield k }
end

def each_value(&block)
return self.enum_for(:each_value) if !block
each { |k, v| yield v }
end

def ==(other)
if self.equal?(other)
return true
@@ -1,4 +1 @@
fails:Hash#each_key calls block once for each key, passing key
fails:Hash#each_key returns an Enumerator if called on a non-empty hash without a block
fails:Hash#each_key returns an Enumerator if called on an empty hash without a block
fails:Hash#each_key returns an Enumerator if called on a frozen instance
@@ -1,6 +1,3 @@
fails:Hash#each_pair yields a [[key, value]] Array for each pair to a block expecting |*args|
fails:Hash#each_pair yields the key and value of each pair to a block expecting |key, value|
fails:Hash#each_pair properly expands (or not) child class's 'each'-yielded args
fails:Hash#each_pair returns an Enumerator if called on a non-empty hash without a block
fails:Hash#each_pair returns an Enumerator if called on an empty hash without a block
fails:Hash#each_pair returns an Enumerator if called on a frozen instance
@@ -1,6 +1,3 @@
fails:Hash#each yields a [[key, value]] Array for each pair to a block expecting |*args|
fails:Hash#each yields the key and value of each pair to a block expecting |key, value|
fails:Hash#each properly expands (or not) child class's 'each'-yielded args
fails:Hash#each returns an Enumerator if called on a non-empty hash without a block
fails:Hash#each returns an Enumerator if called on an empty hash without a block
fails:Hash#each returns an Enumerator if called on a frozen instance
@@ -1,5 +1 @@
fails:Hash#each_value calls block once for each key, passing value
fails:Hash#each_value processes values in the same order as values()
fails:Hash#each_value returns an Enumerator if called on a non-empty hash without a block
fails:Hash#each_value returns an Enumerator if called on an empty hash without a block
fails:Hash#each_value returns an Enumerator if called on a frozen instance

0 comments on commit a549656

Please sign in to comment.
You can’t perform that action at this time.