fix layout
amazing at this stage, but yet another index error the strange (and wonderful) thing is that changing the return of the one function just shifts the variables and everything else stays intact. Thus are the wonders of object orientation
This commit is contained in:
parent
17545d1525
commit
4ce4775902
@ -62,12 +62,13 @@ module Parfait
|
||||
raise "should not rely on layout internal structure, use variable_index"
|
||||
end
|
||||
|
||||
# index of a variable name into the layout.
|
||||
# layout is a list, so lowest index is 1
|
||||
# :layout is a variable for every object, so 1 is taken for :layout
|
||||
# still, the index is the same.
|
||||
# index of the variable when using internal_object_get
|
||||
# (internal_object_get is 1 based and 1 is always the layout)
|
||||
def variable_index name
|
||||
list_index(name)
|
||||
has = list_index(name)
|
||||
return nil unless has
|
||||
raise "internal error #{name}:#{has}" if has < 2
|
||||
has - 1
|
||||
end
|
||||
|
||||
def inspect
|
||||
|
@ -16,7 +16,7 @@ class TestLayout < MiniTest::Test
|
||||
def test_message_by_index
|
||||
assert_equal @mess.next_message , @mess.get_instance_variable(:next_message)
|
||||
index = @mess.get_layout.variable_index :next_message
|
||||
assert_equal 3 , index
|
||||
assert_equal 2 , index
|
||||
assert_equal @mess.next_message , @mess.internal_object_get(index)
|
||||
end
|
||||
|
||||
@ -33,7 +33,7 @@ class TestLayout < MiniTest::Test
|
||||
end
|
||||
def test_layout_is_first
|
||||
layout = @mess.get_layout
|
||||
assert_equal nil , layout.variable_index(:layout)
|
||||
assert_equal 1 , layout.variable_index(:layout)
|
||||
end
|
||||
|
||||
def test_no_index_below_1
|
||||
@ -53,4 +53,26 @@ class TestLayout < MiniTest::Test
|
||||
assert_equal layout.object_instance_names.get_length , 0
|
||||
#assert_equal layout.first , :layout
|
||||
end
|
||||
|
||||
def test_attribute_set
|
||||
@mess.receiver = 55
|
||||
assert_equal 55 , @mess.receiver
|
||||
end
|
||||
|
||||
# not really parfait test, but related and no other place currently
|
||||
def test_reg_index
|
||||
message_ind = Register.resolve_index( :message , :receiver )
|
||||
assert_equal 3 , message_ind
|
||||
@mess.receiver = 55
|
||||
assert_equal 55 , @mess.internal_object_get(message_ind)
|
||||
end
|
||||
|
||||
def test_object_layout
|
||||
assert_equal 2 , @mess.get_layout.variable_index(:next_message)
|
||||
end
|
||||
|
||||
def test_remove_me
|
||||
layout = @mess.get_layout
|
||||
assert_equal layout , @mess.internal_object_get(1)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user