From 3fb08acf3f83aa403b095aa60be1702419d8a66d Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 28 Jul 2015 16:19:10 +0300 Subject: [PATCH] better tests to find sneaky module bug --- lib/parfait/module.rb | 3 ++- lib/parfait/space.rb | 1 + test/parfait/test_space.rb | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib/parfait/module.rb b/lib/parfait/module.rb index e177a525..f74d9405 100644 --- a/lib/parfait/module.rb +++ b/lib/parfait/module.rb @@ -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 diff --git a/lib/parfait/space.rb b/lib/parfait/space.rb index 569232db..bb92509f 100644 --- a/lib/parfait/space.rb +++ b/lib/parfait/space.rb @@ -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 diff --git a/test/parfait/test_space.rb b/test/parfait/test_space.rb index 4ff032b8..a58e12f9 100644 --- a/test/parfait/test_space.rb +++ b/test/parfait/test_space.rb @@ -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