fix classic index bug
This commit is contained in:
parent
6786855e95
commit
1170761922
@ -24,7 +24,7 @@ module Parfait
|
|||||||
def index_of( item )
|
def index_of( item )
|
||||||
max = self.get_length
|
max = self.get_length
|
||||||
counter = 1
|
counter = 1
|
||||||
while( counter < max )
|
while( counter <= max )
|
||||||
if( get(counter) == item)
|
if( get(counter) == item)
|
||||||
return counter
|
return counter
|
||||||
end
|
end
|
||||||
|
@ -52,6 +52,7 @@ class TestList < MiniTest::Test
|
|||||||
def test_index_of
|
def test_index_of
|
||||||
test_many_get
|
test_many_get
|
||||||
assert_equal 2 , @list.index_of( :two )
|
assert_equal 2 , @list.index_of( :two )
|
||||||
|
assert_equal 3 , @list.index_of( :three )
|
||||||
assert_equal nil , @list.index_of( :four )
|
assert_equal nil , @list.index_of( :four )
|
||||||
end
|
end
|
||||||
def test_incude
|
def test_incude
|
||||||
|
Loading…
Reference in New Issue
Block a user