let spce keep the messages in a factory #14

Like Integers and addresses before, messages are now in a factory
Factories keep allocated (uninitialised) objects, had to make init public to call it
This commit is contained in:
Torsten Ruger
2018-09-01 11:24:16 +03:00
parent 0a390cc5a9
commit d964e9ea9d
10 changed files with 39 additions and 35 deletions

View File

@ -5,7 +5,7 @@ module Parfait
def setup
super
@mess = @space.next_message
@mess = @space.get_next_for(:Message)
@type = @mess.get_type
end

View File

@ -5,7 +5,7 @@ module Parfait
def setup
super
@mess = @space.next_message
@mess = @space.get_next_for(:Message)
end
def test_length
assert_equal 9 , @mess.get_type.instance_length , @mess.get_type.inspect

View File

@ -5,7 +5,7 @@ module Parfait
def setup
super
@named_list = @space.next_message.frame
@named_list = @space.get_next_for(:Message).frame
@type = @named_list.get_type
end

View File

@ -11,7 +11,7 @@ module Parfait
end
def test_space_length
assert_equal 9 , @space.get_type.instance_length , @space.get_type.inspect
assert_equal 7 , @space.get_type.instance_length , @space.get_type.inspect
end
def test_singletons
assert @space.true_object , "No truth"
@ -92,7 +92,7 @@ module Parfait
assert_equal Dictionary , @space.factories.class
end
def test_factory_length
assert_equal 2 , @space.factories.length
assert_equal 3 , @space.factories.length
end
def test_has_integer_factory
ints = @space.get_factory_for(:Integer)
@ -126,23 +126,27 @@ module Parfait
end
assert_equal 1014, count
end
def test_messages
mess = @space.messages
all = []
while mess
all << mess
def test_has_message_factory
ints = @space.get_factory_for(:Message)
assert_equal Factory , ints.class
assert_equal :Message , ints.for_type.class_name
end
def test_has_messages
nekst = @space.get_next_for(:Message)
assert_equal Parfait::Message , nekst.class
end
def test_has_next_message
assert_equal Parfait::Message , @space.get_next_for(:Message).class
end
def test_message_count
mess = @space.get_next_for(:Message)
count = 0
while(mess)
count += 1
assert mess.frame
mess = mess.next_message
end
assert_equal all.length , all.uniq.length
# there is a 5.times in space, but one Message gets created before
assert_equal 50 + 1 , all.length
end
def test_message_vars
mess = @space.next_message
all = mess.get_instance_variables
assert all
assert all.include?(:next_message)
assert_equal 1014, count
end
def test_create_class
assert @space.create_class( :NewClass )

View File

@ -5,7 +5,7 @@ module Parfait
def setup
super
@mess = @space.next_message
@mess = @space.get_next_for(:Message)
assert @mess
@type = @mess.get_type()
end

View File

@ -5,7 +5,7 @@ module Parfait
def setup
super
@mess = @space.next_message
@mess = @space.get_next_for(:Message)
end
def test_message_type

View File

@ -27,7 +27,7 @@ module Parfait
assert_equal Parfait::Space , space.class
type = space.get_type
assert_equal Parfait::Type , type.class
assert_equal 9 , type.names.get_length
assert_equal 7 , type.names.get_length
assert_equal type.object_class.class , Parfait::Class
assert_equal type.object_class.name , :Space
end