Fix ruby normalising to_vool

So that vool layer never has complex conditions or returns
Start with while, next if, return and assign
This commit is contained in:
2019-08-16 14:09:56 +03:00
parent 84b9811e55
commit c213cf874b
10 changed files with 40 additions and 31 deletions

View File

@ -22,20 +22,20 @@ module Ruby
class TestWhileStatementHoist < MiniTest::Test
include RubyTests
def setup
@lst = compile( "while(arg > 1) ; arg = 1 ; end" ).to_vool
@lst = compile( "while(call(arg > 1)) ; arg = 1 ; end" ).to_vool
end
def test_class
assert_equal Vool::WhileStatement , @lst.class
assert_equal Vool::LocalAssignment , @lst.body.class
end
def test_condition_class
assert_equal Vool::LocalVariable , @lst.condition.class
assert_equal Vool::SendStatement , @lst.condition.class
end
def test_hoist
assert_equal Vool::LocalAssignment , @lst.hoisted.class
assert_equal Vool::Statements , @lst.hoisted.class
end
def test_hoist_is_cond
assert_equal @lst.hoisted.name , @lst.condition.name
def test_hoist_is_assi
assert_equal Vool::LocalAssignment , @lst.hoisted.first.class
end
end
end