add create_method for layout too
as for class, same signature some more test for behavior
This commit is contained in:
parent
9d0b264b79
commit
abaa56fbba
@ -80,6 +80,17 @@ module Parfait
|
||||
def sof_reference_name
|
||||
"#{self.object_class.name}_Layout"
|
||||
end
|
||||
alias :name :sof_reference_name
|
||||
|
||||
def super_class_name
|
||||
nil # stop resolve recursing up metaclasses
|
||||
end
|
||||
|
||||
def create_instance_method method_name , arguments
|
||||
raise "create_instance_method #{method_name}.#{method_name.class}" unless method_name.is_a?(Symbol)
|
||||
#puts "Self: #{self.class} clazz: #{clazz.name}"
|
||||
add_instance_method Method.new( self , method_name , arguments )
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -5,7 +5,6 @@ class TestMeta < MiniTest::Test
|
||||
def setup
|
||||
@space = Register.machine.boot.space
|
||||
@try = @space.create_class(:Try , :Object).meta
|
||||
puts @try.class
|
||||
end
|
||||
|
||||
def foo_method for_class = :Try
|
||||
@ -20,44 +19,44 @@ class TestMeta < MiniTest::Test
|
||||
assert @space.get_class_by_name(:Object).meta
|
||||
end
|
||||
|
||||
def pest_new_methods
|
||||
def test_new_methods
|
||||
assert_equal @try.method_names.class, @try.instance_methods.class
|
||||
assert_equal @try.method_names.get_length , @try.instance_methods.get_length
|
||||
assert_equal 0 , @try.method_names.get_length
|
||||
end
|
||||
def pest_add_method
|
||||
|
||||
def test_init_methods
|
||||
assert_equal 3 , @try.get_layout.variable_index(:instance_methods)
|
||||
@try.instance_methods = Parfait::List.new
|
||||
assert_equal @try.instance_methods , @try.internal_object_get(3)
|
||||
assert @try.instance_methods
|
||||
end
|
||||
def test_create_method
|
||||
@try.create_instance_method :bar, Register.new_list( [ Parfait::Variable.new(:Integer , :bar )])
|
||||
assert_equal ":bar" , @try.method_names.inspect
|
||||
end
|
||||
def test_add_method
|
||||
foo = foo_method
|
||||
assert_equal foo , @try.add_instance_method(foo)
|
||||
assert_equal 1 , @try.instance_methods.get_length
|
||||
assert_equal ":foo" , @try.method_names.inspect
|
||||
end
|
||||
def pest_remove_method
|
||||
pest_add_method
|
||||
def test_remove_method
|
||||
test_add_method
|
||||
assert_equal true , @try.remove_instance_method(:foo)
|
||||
end
|
||||
def pest_remove_nothere
|
||||
def test_remove_nothere
|
||||
assert_raises RuntimeError do
|
||||
@try.remove_instance_method(:foo)
|
||||
end
|
||||
end
|
||||
def pest_create_method
|
||||
@try.create_instance_method :bar, Register.new_list( [ Parfait::Variable.new(:Integer , :bar )])
|
||||
assert_equal ":bar" , @try.method_names.inspect
|
||||
end
|
||||
def pest_method_get
|
||||
pest_add_method
|
||||
def test_method_get
|
||||
test_add_method
|
||||
assert_equal Parfait::Method , @try.get_instance_method(:foo).class
|
||||
end
|
||||
def pest_method_get_nothere
|
||||
def test_method_get_nothere
|
||||
assert_equal nil , @try.get_instance_method(:foo)
|
||||
pest_remove_method
|
||||
test_remove_method
|
||||
assert_equal nil , @try.get_instance_method(:foo)
|
||||
end
|
||||
def pest_resolve
|
||||
foo = foo_method :Object
|
||||
@space.get_class_by_name(:Object).add_instance_method(foo)
|
||||
assert_equal :foo , @try.resolve_method(:foo).name
|
||||
end
|
||||
def pest_meta
|
||||
assert @try.meta_class
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user