fixed layout inspect bug
This commit is contained in:
parent
885aa765d6
commit
55dd5f74fc
@ -124,10 +124,7 @@ module Parfait
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
inspect_from 1
|
index = 1
|
||||||
end
|
|
||||||
|
|
||||||
def inspect_from index
|
|
||||||
ret = ""
|
ret = ""
|
||||||
while index <= self.get_length
|
while index <= self.get_length
|
||||||
item = get(index)
|
item = get(index)
|
||||||
|
@ -34,6 +34,7 @@ module Parfait
|
|||||||
def initialize( object_class )
|
def initialize( object_class )
|
||||||
super()
|
super()
|
||||||
self.object_class = object_class
|
self.object_class = object_class
|
||||||
|
add_instance_variable :layout
|
||||||
end
|
end
|
||||||
|
|
||||||
def == other
|
def == other
|
||||||
@ -73,7 +74,7 @@ module Parfait
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
"Layout[#{inspect_from(3)}]"
|
"Layout[#{super}]"
|
||||||
end
|
end
|
||||||
|
|
||||||
def sof_reference_name
|
def sof_reference_name
|
||||||
|
@ -36,6 +36,23 @@ class TestLayout < MiniTest::Test
|
|||||||
assert_equal 8 , @mess.get_layout.instance_length , @mess.get_layout.inspect
|
assert_equal 8 , @mess.get_layout.instance_length , @mess.get_layout.inspect
|
||||||
end
|
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
|
def test_no_index_below_1
|
||||||
layout = @mess.get_layout
|
layout = @mess.get_layout
|
||||||
names = layout.instance_names
|
names = layout.instance_names
|
||||||
@ -59,6 +76,31 @@ class TestLayout < MiniTest::Test
|
|||||||
assert_equal 55 , @mess.receiver
|
assert_equal 55 , @mess.receiver
|
||||||
end
|
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
|
# not really parfait test, but related and no other place currently
|
||||||
def test_reg_index
|
def test_reg_index
|
||||||
message_ind = Register.resolve_index( :message , :receiver )
|
message_ind = Register.resolve_index( :message , :receiver )
|
||||||
|
@ -124,6 +124,11 @@ class TestList < MiniTest::Test
|
|||||||
assert_equal 3 , @list.index_of( :three )
|
assert_equal 3 , @list.index_of( :three )
|
||||||
assert_equal nil , @list.index_of( :four )
|
assert_equal nil , @list.index_of( :four )
|
||||||
end
|
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
|
def test_inlcude
|
||||||
test_many_get
|
test_many_get
|
||||||
assert_equal true , @list.include?( :two )
|
assert_equal true , @list.include?( :two )
|
||||||
|
Loading…
Reference in New Issue
Block a user