From f8cb33ec5e6fe4696d30f7d551394af144a853e4 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 20 Jul 2015 13:20:43 +0300 Subject: [PATCH] test ivar name list --- lib/parfait/layout.rb | 12 ++++++++++++ lib/parfait/object.rb | 2 +- test/parfait/test_space.rb | 10 ++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/parfait/layout.rb b/lib/parfait/layout.rb index 63081bb0..3054dbb6 100644 --- a/lib/parfait/layout.rb +++ b/lib/parfait/layout.rb @@ -48,6 +48,18 @@ module Parfait return @object_class end + def object_instance_names + names = List.new + index = 1 + while index <= self.get_length + item = get(index) + names.push item + index = index + 1 + end + self + + names + end def sof_reference_name "#{@object_class.name}_Layout" end diff --git a/lib/parfait/object.rb b/lib/parfait/object.rb index d14e5d79..5fd3f43a 100644 --- a/lib/parfait/object.rb +++ b/lib/parfait/object.rb @@ -65,7 +65,7 @@ module Parfait end def get_instance_variables - get_layout().get_instance_variables + get_layout().object_instance_names end def get_instance_variable name diff --git a/test/parfait/test_space.rb b/test/parfait/test_space.rb index b8b3605f..4ff032b8 100644 --- a/test/parfait/test_space.rb +++ b/test/parfait/test_space.rb @@ -34,13 +34,19 @@ class TestSpace < MiniTest::Test # there is a 5.times in space, but one Message gets created before assert_equal 5 + 1 , all.length end + def test_message_vars + mess = @machine.space.first_message + all = mess.get_instance_variables + assert all + assert all.include?(:next_message) + end + def test_message_layout mess = @machine.space.first_message one_way = mess.get_layout assert one_way assert mess.instance_variable_defined :next_message - other_way = mess.get_instance_variable :layout - #puts mess.get_instance_variables +# other_way = mess.get_instance_variable :layout # assert other_way # assert_equal one_way , other_way , "not same "