From db5c958d2e0548935b8f7c13efd15f709f682d67 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 31 May 2015 13:26:47 +0300 Subject: [PATCH] fix lists first --- lib/parfait/list.rb | 2 +- test/parfait/test_list.rb | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/parfait/list.rb b/lib/parfait/list.rb index 06aacae1..2f4a22ce 100644 --- a/lib/parfait/list.rb +++ b/lib/parfait/list.rb @@ -65,7 +65,7 @@ module Parfait end def first - return nil unless empty? + return nil if empty? get(1) end diff --git a/test/parfait/test_list.rb b/test/parfait/test_list.rb index e847e5f3..7f86e5a7 100644 --- a/test/parfait/test_list.rb +++ b/test/parfait/test_list.rb @@ -68,9 +68,23 @@ class TestList < MiniTest::Test assert_equal 3 , @list.index_of( :three ) assert_equal nil , @list.index_of( :four ) end - def test_incude + def test_inlcude test_many_get assert_equal true , @list.include?( :two ) assert_equal false , @list.include?( :four ) 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