renamed array and hash to list and dictionary

Since these are not the ruby classes, we don’t need
the old names. They are misleading.
An Array is a military term, we mean list
And a Hash is an implementation of a Dictionary,
or LookupTable
This commit is contained in:
Torsten Ruger
2015-05-12 19:10:45 +03:00
parent a94ce51c58
commit dd41758dea
10 changed files with 21 additions and 21 deletions

41
test/parfait/test_list.rb Normal file
View File

@ -0,0 +1,41 @@
require_relative "../helper"
class TestList < MiniTest::Test
def setup
@list = ::Parfait::List.new_object
end
def test_list_create
assert @list.empty?
end
def test_empty_list_doesnt_return
assert_equal nil , @list.get(3)
end
def test_one_set0
assert_equal 1 , @list.set(0,1)
end
def test_one_set1
assert_equal :some , @list.set(1,:some)
end
def test_two_sets
assert_equal 1 , @list.set(0,1)
assert_equal :some , @list.set(1,:some)
end
def test_one_get1
test_one_set0
assert_equal 1 , @list.get(0)
end
def test_one_get2
test_one_set1
assert_equal :some , @list.get(1)
end
def test_many_get
shouldda = { 1 => :one , 2 => :two , 3 => :three}
shouldda.each do |k,v|
@list.set(k,v)
end
shouldda.each do |k,v|
assert_equal v , @list.get(k)
end
end
end