rubyx/test/vool/ruby_compiler/test_method_statement.rb

41 lines
1.0 KiB
Ruby
Raw Normal View History

require_relative "helper"
2017-04-01 15:27:32 +02:00
module Vool
class TestMethodStatement < MiniTest::Test
2017-04-06 13:02:18 +02:00
def basic_setup()
input = "def tryout(arg1, arg2) ; true ; false ; end "
@lst = RubyCompiler.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
def test_body_is_scope_one_statement
input = "def tryout(arg1, arg2) ; true ; end "
lst = RubyCompiler.compile( input )
assert_equal ScopeStatement , lst.body.class
end
def test_body_is_scope_zero_statement
input = "def tryout(arg1, arg2) ; ; end "
lst = RubyCompiler.compile( input )
assert_equal ScopeStatement , lst.body.class
end
2017-04-01 15:27:32 +02:00
end
end