rubyx/test/ruby/test_method_statement2.rb
Torsten Rüger d1f8733623 Rename Vool to Sol
Simple is really the descriptive name for the layer
Sure, it is "virtual" but that is not as important as the fact that it is simple (or simplified)
Also objct (based really) is better, since orientated implies it is a little like that, but only orientated, not really it. Sol only has objects, nothing else
Just cause i was renaming anyway
2019-10-04 00:38:47 +03:00

54 lines
2.1 KiB
Ruby

require_relative "helper"
module Ruby
# other Return tests (standalone?) only test the statement
# But to get the implicit return, we test the method, as it inserts
# the implicit return
class TestMethodStatementRet < MiniTest::Test
include RubyTests
def test_single_const
@lst = compile( "def tryout(arg1, arg2) ; true ; end " ).to_sol
assert_equal Sol::ReturnStatement , @lst.body.class
end
def test_single_instance
@lst = compile( "def tryout(arg1, arg2) ; @a ; end " ).to_sol
assert_equal Sol::ReturnStatement , @lst.body.class
end
def test_single_call
@lst = compile( "def tryout(arg1, arg2) ; is_true() ; end " ).to_sol
assert_equal Sol::ReturnStatement , @lst.body.class
end
def test_multi_const
@lst = compile( "def tryout(arg1, arg2) ; @a = some_call(); true ; end " ).to_sol
assert_equal Sol::ReturnStatement , @lst.body.last.class
end
def test_multi_instance
@lst = compile( "def tryout(arg1, arg2) ; @a = some_call(); @a ; end " ).to_sol
assert_equal Sol::ReturnStatement , @lst.body.last.class
end
def test_multi_call
@lst = compile( "def tryout(arg1, arg2) ; is_true() ; some_call() ; end " ).to_sol
assert_equal Sol::ReturnStatement , @lst.body.last.class
end
def test_return
@lst = compile( "def tryout(arg1, arg2) ; return 1 ; end " ).to_sol
assert_equal Sol::ReturnStatement , @lst.body.class
assert_equal Sol::IntegerConstant , @lst.body.return_value.class
end
def test_local_assign
@lst = compile( "def tryout(arg1, arg2) ; a = 1 ; end " ).to_sol
assert_equal Sol::Statements , @lst.body.class
assert_equal Sol::ReturnStatement , @lst.body.last.class
assert_equal Sol::LocalVariable , @lst.body.last.return_value.class
end
def test_local_assign
@lst = compile( "def tryout(arg1, arg2) ; @a = 1 ; end " ).to_sol
assert_equal Sol::Statements , @lst.body.class
assert_equal Sol::ReturnStatement , @lst.body.last.class
assert_equal Sol::InstanceVariable , @lst.body.last.return_value.class
end
end
end