many minor parfait fixes
This commit is contained in:
parent
3bdba119c8
commit
e70bfb9f7a
@ -17,7 +17,7 @@ module Parfait
|
||||
end
|
||||
|
||||
def length()
|
||||
return @keys.length()
|
||||
return @keys.get_length()
|
||||
end
|
||||
|
||||
def get(key)
|
||||
@ -33,10 +33,10 @@ module Parfait
|
||||
end
|
||||
|
||||
def key_index(key)
|
||||
len = @keys.length()
|
||||
index = 0
|
||||
len = @keys.get_length()
|
||||
index = 1
|
||||
found = nil
|
||||
while(index < len)
|
||||
while(index <= len)
|
||||
if( @keys.get(index) == key)
|
||||
found = index
|
||||
break
|
||||
|
@ -51,7 +51,7 @@ module Parfait
|
||||
# set the value at index.
|
||||
# Lists start from index 1
|
||||
def get(index)
|
||||
raise "Only positive indexes, #{len}" if index <= 0
|
||||
raise "Only positive indexes, #{index}" if index <= 0
|
||||
if index > self.get_length
|
||||
return nil
|
||||
else
|
||||
|
@ -5,10 +5,10 @@ class TestDictionary < MiniTest::Test
|
||||
def setup
|
||||
@lookup = ::Parfait::Dictionary.new
|
||||
end
|
||||
def test_list_create
|
||||
def test_dict_create
|
||||
assert @lookup.empty?
|
||||
end
|
||||
def test_empty_list_doesnt_return
|
||||
def test_empty_dict_doesnt_return
|
||||
assert_equal nil , @lookup.get(3)
|
||||
assert_equal nil , @lookup.get(:any)
|
||||
end
|
||||
|
@ -6,16 +6,16 @@ class TestObject < MiniTest::Test
|
||||
@object = ::Parfait::Object.new_object
|
||||
end
|
||||
|
||||
def test_list_create
|
||||
def test_object_create
|
||||
assert_equal 1 , @object.internal_object_length
|
||||
end
|
||||
|
||||
def test_list_grow
|
||||
def test_object_grow
|
||||
@object.internal_object_grow( 2 )
|
||||
assert_equal 2 , @object.internal_object_length
|
||||
end
|
||||
|
||||
def test_empty_list_doesnt_return
|
||||
def test_empty_object_doesnt_return
|
||||
assert_equal nil , @object.internal_object_get(3)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user