fixed layout inspect bug

This commit is contained in:
Torsten Ruger 2015-10-26 15:07:59 +02:00
parent 885aa765d6
commit 55dd5f74fc
4 changed files with 50 additions and 5 deletions

View File

@ -124,10 +124,7 @@ module Parfait
end
def inspect
inspect_from 1
end
def inspect_from index
index = 1
ret = ""
while index <= self.get_length
item = get(index)

View File

@ -34,6 +34,7 @@ module Parfait
def initialize( object_class )
super()
self.object_class = object_class
add_instance_variable :layout
end
def == other
@ -73,7 +74,7 @@ module Parfait
end
def inspect
"Layout[#{inspect_from(3)}]"
"Layout[#{super}]"
end
def sof_reference_name

View File

@ -36,6 +36,23 @@ class TestLayout < MiniTest::Test
assert_equal 8 , @mess.get_layout.instance_length , @mess.get_layout.inspect
end
def test_layout_length
assert_equal 8 , @mess.get_layout.indexed_length , @mess.get_layout.inspect
assert_equal 8 , @mess.get_layout.internal_object_get(4)
end
def test_layout_length_index
assert_equal 4 , @mess.get_layout.get_layout.variable_index(:indexed_length)
assert_equal 4 , @mess.get_layout.get_layout.get_offset
assert_equal 4 , @mess.get_layout.get_offset
assert_equal 4 , @mess.get_layout.get_layout.indexed_length
assert_equal 4 , @mess.get_layout.get_layout.internal_object_get(4)
end
def test_layout_methods
assert_equal 3 , @mess.get_layout.get_layout.variable_index(:instance_methods)
end
def test_no_index_below_1
layout = @mess.get_layout
names = layout.instance_names
@ -59,6 +76,31 @@ class TestLayout < MiniTest::Test
assert_equal 55 , @mess.receiver
end
def test_add_name
layout = Parfait::Layout.new Register.machine.space.get_class_by_name(:Layout)
layout.add_instance_variable :boo
assert_equal 2 , layout.variable_index(:boo)
assert_equal 2 , layout.get_length
assert_equal :layout , layout.get(1)
assert_equal :boo , layout.get(2)
layout
end
def test_inspect
layout = test_add_name
assert layout.inspect.include?("boo") , layout.inspect
end
def test_each
layout = test_add_name
assert_equal 2 , layout.get_length
counter = [:boo , :layout]
layout.each do |item|
assert_equal item , counter.delete(item)
end
assert counter.empty?
end
# not really parfait test, but related and no other place currently
def test_reg_index
message_ind = Register.resolve_index( :message , :receiver )

View File

@ -124,6 +124,11 @@ class TestList < MiniTest::Test
assert_equal 3 , @list.index_of( :three )
assert_equal nil , @list.index_of( :four )
end
def test_inspect
test_many_get
assert @list.inspect.include?("one") , @list.inspect
assert @list.inspect.include?("three") , @list.inspect
end
def test_inlcude
test_many_get
assert_equal true , @list.include?( :two )