fix method to_vool
This commit is contained in:
parent
7b4a0126f7
commit
238f09b5ad
@ -9,7 +9,7 @@ module Ruby
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_vool
|
def to_vool
|
||||||
MethodStatement.new( @name , @args , @body.normalize)
|
Vool::MethodStatement.new( @name , @args.dup , @body.to_vool)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(depth = 0)
|
def to_s(depth = 0)
|
||||||
|
@ -1,32 +1,47 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
|
class TestMethodStatementTrans < MiniTest::Test
|
||||||
|
include RubyTests
|
||||||
|
|
||||||
|
def setup()
|
||||||
|
input = "def tryout(arg1, arg2) ; a = arg1 ; end "
|
||||||
|
@lst = compile( input ).to_vool
|
||||||
|
end
|
||||||
|
def test_method
|
||||||
|
assert_equal Vool::MethodStatement , @lst.class
|
||||||
|
end
|
||||||
|
def test_method_args
|
||||||
|
assert_equal [:arg1, :arg2] , @lst.args
|
||||||
|
end
|
||||||
|
def test_body_is_scope_zero_statement
|
||||||
|
assert_equal Vool::LocalAssignment , @lst.body.class
|
||||||
|
end
|
||||||
|
end
|
||||||
class TestMethodStatement < MiniTest::Test
|
class TestMethodStatement < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def basic_setup()
|
def setup()
|
||||||
input = "def tryout(arg1, arg2) ; true ; false ; end "
|
input = "def tryout(arg1, arg2) ; true ; false ; end "
|
||||||
@lst = compile( input )
|
@lst = compile( input )
|
||||||
end
|
end
|
||||||
def test_method
|
def test_method
|
||||||
basic_setup
|
|
||||||
assert_equal MethodStatement , @lst.class
|
assert_equal MethodStatement , @lst.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_method_name
|
def test_method_name
|
||||||
basic_setup
|
|
||||||
assert_equal :tryout , @lst.name
|
assert_equal :tryout , @lst.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_method_args
|
def test_method_args
|
||||||
basic_setup
|
|
||||||
assert_equal [:arg1, :arg2] , @lst.args
|
assert_equal [:arg1, :arg2] , @lst.args
|
||||||
end
|
end
|
||||||
def test_basic_body
|
def test_basic_body
|
||||||
basic_setup
|
|
||||||
assert_equal ScopeStatement , @lst.body.class
|
assert_equal ScopeStatement , @lst.body.class
|
||||||
assert_equal 2 , @lst.body.length
|
assert_equal 2 , @lst.body.length
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
class TestMethodStatement2 < MiniTest::Test
|
||||||
|
include RubyTests
|
||||||
def test_body_is_scope_one_statement
|
def test_body_is_scope_one_statement
|
||||||
input = "def tryout(arg1, arg2) ; a = true ; end "
|
input = "def tryout(arg1, arg2) ; a = true ; end "
|
||||||
lst = compile( input )
|
lst = compile( input )
|
||||||
|
Loading…
Reference in New Issue
Block a user