better tests to find sneaky module bug

This commit is contained in:
Torsten Ruger 2015-07-28 16:19:10 +03:00
parent 5fd04ee0c5
commit 3fb08acf3f
3 changed files with 36 additions and 3 deletions

View File

@ -54,8 +54,9 @@ module Parfait
def create_instance_method method_name , arg_names
raise "uups #{method_name}.#{method_name.class}" unless method_name.is_a?(Symbol)
clazz = get_layout().object_class()
clazz = object_layout().object_class()
raise "??? #{method_name}" unless clazz
puts "Self: #{self.class} clazz: #{clazz.name}"
Method.new( clazz , method_name , arg_names )
end

View File

@ -63,6 +63,7 @@ module Parfait
raise "uups #{name}.#{name.class}" unless name.is_a?(Symbol)
c = self.classes[name]
#puts "MISS, no class #{name} #{name.class}" unless c # " #{self.classes}"
#puts "CLAZZ, #{name} #{c.get_layout.get_length}" if c
c
end

View File

@ -6,6 +6,9 @@ class TestSpace < MiniTest::Test
@machine = Virtual.machine
@machine.boot
end
def classes
[:Kernel,:Word,:List,:Message,:Frame,:Layout,:Class,:Dictionary,:Method]
end
def test_booted
assert_equal true , @machine.booted
end
@ -15,11 +18,39 @@ class TestSpace < MiniTest::Test
def test_global_space
assert_equal Parfait::Space , Parfait::Space.object_space.class
end
def test_classes
[:Kernel,:Word,:List,:Message,:Frame,:Layout,:Class,:Dictionary,:Method].each do |name|
def test_classes_class
classes.each do |name|
assert_equal :Class , @machine.space.classes[name].get_class.name
assert_equal Parfait::Class , @machine.space.classes[name].class
assert_equal Parfait::Layout , @machine.space.classes[name].get_layout.class
assert_equal name , @machine.space.classes[name].get_class.name
end
end
def test_classes_class
classes.each do |name|
assert_equal :Class , @machine.space.classes[name].get_class.name
assert_equal Parfait::Class , @machine.space.classes[name].class
end
end
def test_classes_layout
classes.each do |name|
assert_equal Parfait::Layout , @machine.space.classes[name].get_layout.class
end
end
def test_classes_name
classes.each do |name|
assert_equal name , @machine.space.classes[name].name
end
end
def test_method_name
classes.each do |name|
cl = @machine.space.classes[name]
cl.method_names.each do |mname|
puts "Mehtod #{mname}"
method = cl.get_instance_method(mname)
assert_equal mname , method.name
assert_equal name , method.for_class.name
end
end
end
def test_messages