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-07 16:57:46 +02:00
|
|
|
class TestMethodStatementX < MiniTest::Test
|
2018-06-29 21:46:39 +02:00
|
|
|
include RubyTests
|
2017-04-01 15:27:32 +02:00
|
|
|
|
2017-04-06 13:02:18 +02:00
|
|
|
def basic_setup()
|
|
|
|
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
|
|
|
|
basic_setup
|
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
|
|
|
|
basic_setup
|
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
|
|
|
|
basic_setup
|
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
|
|
|
|
basic_setup
|
|
|
|
assert_equal ScopeStatement , @lst.body.class
|
|
|
|
assert_equal 2 , @lst.body.length
|
2017-04-01 15:27:32 +02:00
|
|
|
end
|
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
|
|
|
|
end
|