fixed the old list tests for hash, and fixed hash to pass them
This commit is contained in:
parent
d3c4087871
commit
da3cd69a5c
@ -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
|
||||||
|
|
||||||
|
@ -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?
|
Loading…
Reference in New Issue
Block a user