fix lists first

This commit is contained in:
Torsten Ruger 2015-05-31 13:26:47 +03:00
parent 03bdc16810
commit db5c958d2e
2 changed files with 16 additions and 2 deletions

View File

@ -65,7 +65,7 @@ module Parfait
end end
def first def first
return nil unless empty? return nil if empty?
get(1) get(1)
end end

View File

@ -68,9 +68,23 @@ class TestList < MiniTest::Test
assert_equal 3 , @list.index_of( :three ) 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_inlcude
test_many_get test_many_get
assert_equal true , @list.include?( :two ) assert_equal true , @list.include?( :two )
assert_equal false , @list.include?( :four ) assert_equal false , @list.include?( :four )
end end
def test_empty_empty
assert_equal true , @list.empty?
end
def test_empty_notempty
assert_equal 1 , @list.set(1,1)
assert_equal false , @list.empty?
end
def test_first
test_many_get
assert_equal :one , @list.first
end
def test_first_empty
assert_equal nil , @list.first
end
end end