add each_with_index to indexed
This commit is contained in:
parent
ad91c0a4bf
commit
137d3c9231
@ -112,6 +112,16 @@ module Parfait
|
||||
self
|
||||
end
|
||||
|
||||
def each_with_index
|
||||
index = 1
|
||||
while index <= self.get_length
|
||||
item = get(index)
|
||||
yield item , index
|
||||
index = index + 1
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def each_pair
|
||||
index = 1
|
||||
while index <= self.get_length
|
||||
|
@ -115,6 +115,12 @@ class TestList < MiniTest::Test
|
||||
end
|
||||
assert_equal 0 , shouldda_values.length
|
||||
end
|
||||
def test_each_index
|
||||
set_shouldda
|
||||
@list.each_with_index do |val , index|
|
||||
assert_equal @list[index] , val
|
||||
end
|
||||
end
|
||||
def test_each_pair_length
|
||||
shouldda_values = set_shouldda.values
|
||||
@list.each_pair do |key,val|
|
||||
|
Loading…
Reference in New Issue
Block a user