linked list of methods instead of list of methods

api changes slightly, especially for each, but mostly sama sama
This commit is contained in:
Torsten Ruger
2018-04-02 16:36:43 +03:00
parent ad497b34f1
commit fb29fb6431
10 changed files with 73 additions and 26 deletions

View File

@ -149,13 +149,13 @@ class TestSpace < MiniTest::Test
def test_no_methods_in_types
test_remove_methods
@space.each_type do |type|
assert_equal 0 , type.methods.get_length , "name #{type.name}"
assert_equal 0 , type.methods_length , "name #{type.name}"
end
end
def test_no_methods_in_classes
test_remove_methods
@space.classes.each do |name , cl|
assert_equal 0 , cl.instance_type.methods.get_length , "name #{cl.name}"
assert_equal 0 , cl.instance_type.methods_length , "name #{cl.name}"
end
end

View File

@ -25,24 +25,30 @@ class TestMethodApi < MiniTest::Test
@space.get_class_by_name(:Object).instance_type
end
def test_new_methods
assert_equal @try_type.method_names.class, @try_type.methods.class
assert_equal @try_type.method_names.get_length , @try_type.methods.get_length
assert_equal Parfait::List , @try_type.method_names.class
assert_equal @try_type.method_names.get_length , @try_type.methods_length
end
def test_add_method
before = @try_type.methods.get_length
before = @try_type.methods_length
add_foo_to
assert_equal 1 , @try_type.methods.get_length - before
assert_equal 1 , @try_type.methods_length - before
assert @try_type.method_names.inspect.include?(":foo")
end
def test_remove_method
add_foo_to
assert_equal true , @try_type.remove_method(:foo)
assert @try_type.remove_method(:foo)
end
def test_remove_not_there
assert_raises RuntimeError do
@try_type.remove_method(:foo)
end
end
def test_remove_method_missing
# assert @try_type.get_method( :method_missing)
assert_raises RuntimeError do
@try_type.remove_method(:method_missing)
end
end
def test_create_method
args = Parfait::Type.for_hash( @try_class , { bar: :Integer})
@try_type.create_method :bar, args , empty_frame