change method locals to type object too (same as args)
This commit is contained in:
@@ -6,6 +6,8 @@ class TestMethod < MiniTest::Test
|
||||
obj = Register.machine.space.get_class_by_name(:Object)
|
||||
args = Parfait::Type.new_for_hash( obj , { bar: :Integer , foo: :Type})
|
||||
@method = ::Parfait::TypedMethod.new obj , :meth , args
|
||||
@method.add_local :local_bar , :Integer
|
||||
@method.add_local :local_foo , :Type
|
||||
end
|
||||
|
||||
def test_method_name
|
||||
@@ -39,7 +41,7 @@ class TestMethod < MiniTest::Test
|
||||
assert_equal 1 , index
|
||||
assert_equal :bar , @method.argument_name(index)
|
||||
end
|
||||
def test_get_arg_name1
|
||||
def test_get_arg_type1
|
||||
index = @method.has_arg(:bar)
|
||||
assert_equal :Integer , @method.argument_type(index)
|
||||
end
|
||||
@@ -48,8 +50,46 @@ class TestMethod < MiniTest::Test
|
||||
assert_equal 2 , index
|
||||
assert_equal :foo , @method.argument_name(index)
|
||||
end
|
||||
def test_get_arg_name2
|
||||
def test_get_arg_type2
|
||||
index = @method.has_arg(:foo)
|
||||
assert_equal :Type , @method.argument_type(index)
|
||||
end
|
||||
|
||||
def test_local1
|
||||
assert_equal 2 , @method.locals_length , @method.locals.inspect
|
||||
assert_equal Symbol , @method.locals.first.class
|
||||
assert_equal :local_bar , @method.locals_name(1)
|
||||
end
|
||||
|
||||
def test_has_local
|
||||
assert_equal 1 , @method.has_local(:local_bar)
|
||||
assert_equal 2 , @method.has_local(:local_foo)
|
||||
end
|
||||
|
||||
def test_add_local
|
||||
@method.add_local(:foo2 , :Object)
|
||||
assert_equal 3 , @method.locals_length
|
||||
assert_equal :foo2 , @method.locals_name(3)
|
||||
assert_equal :Object , @method.locals_type(3)
|
||||
end
|
||||
|
||||
def test_get_locals_name1
|
||||
index = @method.has_local(:local_bar)
|
||||
assert_equal 1 , index
|
||||
assert_equal :local_bar , @method.locals_name(index)
|
||||
end
|
||||
def test_get_locals_type1
|
||||
index = @method.has_local(:local_bar)
|
||||
assert_equal :Integer , @method.locals_type(index)
|
||||
end
|
||||
def test_get_locals_name2
|
||||
index = @method.has_local(:local_foo)
|
||||
assert_equal 2 , index
|
||||
assert_equal :local_foo , @method.locals_name(index)
|
||||
end
|
||||
def test_get_locals_type2
|
||||
index = @method.has_local(:local_bar)
|
||||
assert_equal :Integer , @method.locals_type(index)
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user