Fix vool assignments after call rework

also small fix for if and return, as they need to execute sneds and yields (not just sends), so testing for Call not SendStatement
This commit is contained in:
2019-08-16 20:39:08 +03:00
parent e6c30d98fb
commit 7c91a08d5b
9 changed files with 103 additions and 44 deletions

View File

@ -8,8 +8,26 @@ module Ruby
def setup
@lst = compile( "@foo = a.call(b)").to_vool
end
def test_s
assert_equal "" , @lst.to_s
def test_class
assert_equal Vool::Statements , @lst.class
end
def test_first_class
assert_equal Vool::LocalAssignment , @lst[0].class
end
def test_first_name
assert @lst[0].name.to_s.start_with?("tmp_")
end
def test_second_class
assert_equal Vool::LocalAssignment , @lst[1].class
end
def test_second_name
assert @lst[1].name.to_s.start_with?("tmp_")
end
def test_last_class
assert_equal Vool::IvarAssignment , @lst[2].class
end
def test_second_name
assert_equal :foo, @lst[2].name
end
end
end

View File

@ -1,28 +1,6 @@
require_relative "helper"
module Ruby
class TestReturnStatementVool < MiniTest::Test
include RubyTests
def test_return_const
lst = compile( "return 1" ).to_vool
assert_equal Vool::ReturnStatement , lst.class
end
def test_return_value
lst = compile( "return 1" ).to_vool
assert_equal 1 , lst.return_value.value
end
def test_return_send
lst = compile( "return foo" ).to_vool
assert_equal Vool::LocalAssignment , lst.first.class
end
def test_return_send
lst = compile( "return foo" ).to_vool
assert lst.last.return_value.name.to_s.start_with?("tmp_")
assert_equal 2, lst.length
end
end
class TestReturnStatement < MiniTest::Test
include RubyTests
@ -43,4 +21,31 @@ module Ruby
end
end
class TestReturnStatementVool < MiniTest::Test
include RubyTests
def test_return_const
lst = compile( "return 1" ).to_vool
assert_equal Vool::ReturnStatement , lst.class
end
def test_return_value
lst = compile( "return 1" ).to_vool
assert_equal 1 , lst.return_value.value
end
def test_return_send
lst = compile( "return foo" ).to_vool
assert_equal Vool::ReturnStatement , lst.class
end
def test_return_send3
lst = compile( "return foo.bar.zoo" ).to_vool
assert_equal Vool::LocalAssignment , lst.first.class
assert lst.first.name.to_s.start_with?("tmp_")
end
def test_return_send4
lst = compile( "return foo.bar.zoo" ).to_vool
assert_equal Vool::ReturnStatement, lst[2].class
assert_equal :zoo, lst[2].return_value.name
end
end
end