2017-04-02 18:13:14 +02:00
|
|
|
require_relative "helper"
|
2017-04-01 15:27:32 +02:00
|
|
|
|
2018-07-19 13:46:51 +02:00
|
|
|
module Ruby
|
2018-07-19 15:30:36 +02:00
|
|
|
class TestMethodStatement < MiniTest::Test
|
2018-06-29 21:46:39 +02:00
|
|
|
include RubyTests
|
2017-04-01 15:27:32 +02:00
|
|
|
|
2018-07-19 20:36:28 +02:00
|
|
|
def setup()
|
2017-04-06 13:02:18 +02:00
|
|
|
input = "def tryout(arg1, arg2) ; true ; false ; end "
|
2018-06-29 21:46:39 +02:00
|
|
|
@lst = compile( input )
|
2017-04-01 15:27:32 +02:00
|
|
|
end
|
2017-04-06 13:02:18 +02:00
|
|
|
def test_method
|
2017-04-01 15:27:32 +02:00
|
|
|
assert_equal MethodStatement , @lst.class
|
|
|
|
end
|
|
|
|
|
2017-04-06 13:02:18 +02:00
|
|
|
def test_method_name
|
2017-04-01 15:27:32 +02:00
|
|
|
assert_equal :tryout , @lst.name
|
|
|
|
end
|
2017-04-06 13:02:18 +02:00
|
|
|
def test_method_args
|
2017-04-01 15:27:32 +02:00
|
|
|
assert_equal [:arg1, :arg2] , @lst.args
|
|
|
|
end
|
2017-04-06 13:02:18 +02:00
|
|
|
def test_basic_body
|
|
|
|
assert_equal ScopeStatement , @lst.body.class
|
|
|
|
assert_equal 2 , @lst.body.length
|
2017-04-01 15:27:32 +02:00
|
|
|
end
|
2018-07-19 20:36:28 +02:00
|
|
|
end
|
|
|
|
class TestMethodStatement2 < MiniTest::Test
|
|
|
|
include RubyTests
|
2017-04-12 10:51:29 +02:00
|
|
|
def test_body_is_scope_one_statement
|
2018-03-15 08:16:56 +01:00
|
|
|
input = "def tryout(arg1, arg2) ; a = true ; end "
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( input )
|
2018-03-15 08:16:56 +01:00
|
|
|
assert_equal LocalAssignment , lst.body.class
|
2017-04-12 10:51:29 +02:00
|
|
|
end
|
|
|
|
def test_body_is_scope_zero_statement
|
2018-03-16 15:09:35 +01:00
|
|
|
input = "def tryout(arg1, arg2) ; arg1 = arg2 ; end "
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( input )
|
2018-03-16 15:09:35 +01:00
|
|
|
assert_equal LocalAssignment , lst.body.class
|
2017-04-12 10:51:29 +02:00
|
|
|
end
|
2017-04-01 15:27:32 +02:00
|
|
|
end
|
2019-02-12 21:36:37 +01:00
|
|
|
|
2019-02-14 18:24:12 +01:00
|
|
|
class TestMethodStatementTrans < MiniTest::Test
|
|
|
|
include RubyTests
|
|
|
|
def setup()
|
|
|
|
input = "def tryout(arg1, arg2) ; a = arg1 ; end "
|
|
|
|
@lst = compile( input ).to_vool
|
2019-02-12 21:36:37 +01:00
|
|
|
end
|
2019-02-14 18:24:12 +01:00
|
|
|
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
|
2019-02-12 21:36:37 +01:00
|
|
|
end
|
|
|
|
end
|
2017-04-01 15:27:32 +02:00
|
|
|
end
|