From da3cd69a5c2df69f8fe167a01311b96087f1d0f9 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 28 Aug 2014 16:28:25 +0300 Subject: [PATCH] fixed the old list tests for hash, and fixed hash to pass them --- lib/parfait/hash.rb | 7 ++++--- test/unit/{list.rb => hash.rb} | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) rename test/unit/{list.rb => hash.rb} (95%) diff --git a/lib/parfait/hash.rb b/lib/parfait/hash.rb index d4b1c4ce..43469d08 100644 --- a/lib/parfait/hash.rb +++ b/lib/parfait/hash.rb @@ -5,7 +5,7 @@ class Hash @values = Array.new() end def empty? - @keys.nil? + @keys.empty? end def length() @@ -15,7 +15,7 @@ class Hash def get(key) index = key_index(key) if( index ) - @keys[index] + @values[index] else nil end @@ -41,8 +41,9 @@ class Hash @keys[index] = value else @keys.push(key) - @value.push(value) + @values.push(value) end + value end end diff --git a/test/unit/list.rb b/test/unit/hash.rb similarity index 95% rename from test/unit/list.rb rename to test/unit/hash.rb index 8f95ad3f..c15b95e5 100644 --- a/test/unit/list.rb +++ b/test/unit/hash.rb @@ -1,9 +1,10 @@ require_relative "../helper" +require "parfait/hash" class TestLists < MiniTest::Test def setup - @list = List.new + @list = Hash.new end def test_list_create assert @list.empty?