fixed the old list tests for hash, and fixed hash to pass them

This commit is contained in:
Torsten Ruger 2014-08-28 16:28:25 +03:00
parent d3c4087871
commit da3cd69a5c
2 changed files with 6 additions and 4 deletions

View File

@ -5,7 +5,7 @@ class Hash
@values = Array.new() @values = Array.new()
end end
def empty? def empty?
@keys.nil? @keys.empty?
end end
def length() def length()
@ -15,7 +15,7 @@ class Hash
def get(key) def get(key)
index = key_index(key) index = key_index(key)
if( index ) if( index )
@keys[index] @values[index]
else else
nil nil
end end
@ -41,8 +41,9 @@ class Hash
@keys[index] = value @keys[index] = value
else else
@keys.push(key) @keys.push(key)
@value.push(value) @values.push(value)
end end
value
end end
end end

View File

@ -1,9 +1,10 @@
require_relative "../helper" require_relative "../helper"
require "parfait/hash"
class TestLists < MiniTest::Test class TestLists < MiniTest::Test
def setup def setup
@list = List.new @list = Hash.new
end end
def test_list_create def test_list_create
assert @list.empty? assert @list.empty?