switch to 0 based indexing

the world rocked for a moment (and more fixes to follow)
also the crumbling of idealism was heard
This commit is contained in:
Torsten Ruger
2018-05-14 11:55:01 +03:00
parent 4856b9891d
commit ab01fa3862
19 changed files with 205 additions and 235 deletions

View File

@ -16,7 +16,7 @@ module Parfait
def test_type_is_first
type = @mess.get_type
assert_equal 1 , type.variable_index(:type)
assert_equal 0 , type.variable_index(:type)
end
def test_length
@ -38,16 +38,16 @@ module Parfait
def test_type_length_index
type = @mess.get_type.get_type
assert_equal 5 , type.variable_index(:methods)
assert_equal type.object_class , type.get_internal_word(4)
assert_equal 4 , type.variable_index(:methods)
assert_equal type.object_class , type.get_internal_word(3)
end
def test_no_index_below_1
def test_no_index_below_0
type = @mess.get_type
names = type.names
assert_equal 9 , names.get_length , names.inspect
names.each do |n|
assert type.variable_index(n) >= 1
assert type.variable_index(n) >= 0
end
end
@ -59,18 +59,18 @@ module Parfait
# not really parfait test, but related and no other place currently
def test_reg_index
message_ind = Risc.resolve_to_index( :message , :receiver )
assert_equal 3 , message_ind
assert_equal 2 , message_ind
@mess.set_receiver( 55)
assert_equal 55 , @mess.get_internal_word(message_ind)
end
def test_instance_type
assert_equal 2 , @mess.get_type.variable_index(:next_message)
assert_equal 1 , @mess.get_type.variable_index(:next_message)
end
def test_remove_me
type = @mess.get_type
assert_equal type , @mess.get_internal_word(1)
assert_equal type , @mess.get_internal_word(0)
end
end
end

View File

@ -18,12 +18,12 @@ module Parfait
def test_message_by_index
assert_equal @mess.next_message , @mess.get_instance_variable(:next_message)
index = @mess.get_type.variable_index :next_message
assert_equal 2 , index
assert_equal 1 , index
assert_equal @mess.next_message , @mess.get_internal_word(index)
end
def test_type_methods
assert_equal 5 , @mess.get_type.get_type.variable_index(:methods)
assert_equal 4 , @mess.get_type.get_type.variable_index(:methods)
end
end

View File

@ -41,21 +41,21 @@ module Parfait
def test_added_name_length
type = test_add_name
assert_equal 2 , type.names.get_length , type.inspect
assert_equal :type , type.names.get(1)
assert_equal :boo , type.names.get(2)
assert_equal :type , type.names.get(0)
assert_equal :boo , type.names.get(1)
end
def test_added_name_index
type = test_add_name
assert_equal 2 , type.variable_index(:boo)
assert_equal :Object , type.type_at(2)
assert_equal 1 , type.variable_index(:boo)
assert_equal :Object , type.type_at(1)
end
def test_basic_var_index
assert_equal 1 , @type.variable_index(:type)
assert_equal 0 , @type.variable_index(:type)
end
def test_basic_type_index
assert_equal :Type , @type.type_at(1)
assert_equal :Type , @type.type_at(0)
end
def test_inspect_added
@ -65,8 +65,8 @@ module Parfait
def test_added_names
type = test_add_name
assert_equal :type , type.names.get(1)
assert_equal :boo , type.names.get(2)
assert_equal :type , type.names.get(0)
assert_equal :boo , type.names.get(1)
assert_equal 2 , type.names.get_length
end