use factory to generte intergers in space

start with just integer factory in space
change all the hand-out code
still #14
This commit is contained in:
Torsten Ruger
2018-08-24 18:49:21 +03:00
parent d396da16e3
commit 71ab369c71
16 changed files with 59 additions and 61 deletions

View File

@ -31,18 +31,6 @@ module Parfait
assert_equal 20 , @int.set_internal_word( Integer.integer_index , 20 )
assert_equal 20 , @int.get_internal_word( Integer.integer_index )
end
def test_integer_first
assert Parfait.object_space.next_integer
end
def test_integer_20
int = Parfait.object_space.next_integer
20.times do
assert int
assert_equal Parfait::Integer , int.class
assert int.get_internal_word(1)
int = int.next_integer
end
end
def test_set
@int.set_value(1)
assert_equal 1 , @int.value

View File

@ -11,7 +11,7 @@ module Parfait
end
def test_space_length
assert_equal 12 , @space.get_type.instance_length , @space.get_type.inspect
assert_equal 11 , @space.get_type.instance_length , @space.get_type.inspect
end
def test_singletons
assert @space.true_object , "No truth"
@ -21,7 +21,6 @@ module Parfait
def test_global_space
assert_equal Parfait::Space , Parfait.object_space.class
end
def test_get_class_by_name
assert_equal Parfait::Class , Parfait.object_space.get_class_by_name(:Space).class
end
@ -31,10 +30,6 @@ module Parfait
def test_get_type_by_class_name_nil
assert_nil Parfait.object_space.get_type_by_class_name(:Spac)
end
def test_get_integer_instance
int = @space.get_integer
assert_equal Integer , int.class
end
def test_classes_class
classes.each do |name|
assert_equal :Class , @space.classes[name].get_class.name
@ -93,12 +88,26 @@ module Parfait
end
end
end
def test_has_factory
assert_equal Dictionary , @space.factories.class
end
def test_factory_length
assert_equal 1 , @space.factories.length
end
def test_has_integer_factory
ints = @space.get_factory_for(:Integer)
assert_equal Factory , ints.class
assert_equal :Integer , ints.for_type.class_name
end
def test_has_integers
assert_equal Parfait::Integer , @space.next_integer.class
assert_equal 0 , @space.next_integer.value
nekst = @space.get_next_for(:Integer)
assert_equal Parfait::Integer , nekst.class
assert_nil nekst.value
end
def test_has_next_integer
assert_equal Parfait::Integer , @space.next_integer.next_integer.class
nekst = @space.get_next_for(:Integer)
nekst = @space.get_next_for(:Integer)
assert_equal Parfait::Integer , nekst.class
end
def test_has_addresses
assert_equal Parfait::ReturnAddress , @space.next_address.class
@ -116,7 +125,6 @@ module Parfait
end
assert_equal 400, count
end
def test_messages
mess = @space.messages
all = []

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 12 , type.names.get_length
assert_equal 11 , type.names.get_length
assert_equal type.object_class.class , Parfait::Class
assert_equal type.object_class.name , :Space
end