2018-07-20 16:51:17 +02:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
module Ruby
|
|
|
|
class TestWhileStatementVool < MiniTest::Test
|
|
|
|
include RubyTests
|
|
|
|
def setup
|
|
|
|
@lst = compile( "while(@arg) ; @arg = 1 ; end" ).to_vool
|
|
|
|
end
|
|
|
|
def test_class
|
|
|
|
assert_equal Vool::WhileStatement , @lst.class
|
|
|
|
end
|
|
|
|
def test_body_class
|
|
|
|
assert_equal Vool::IvarAssignment , @lst.body.class
|
|
|
|
end
|
|
|
|
def test_condition_class
|
|
|
|
assert_equal Vool::InstanceVariable , @lst.condition.class
|
|
|
|
end
|
|
|
|
def test_no_hoist
|
|
|
|
assert_nil @lst.hoisted
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestWhileStatementHoist < MiniTest::Test
|
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-08-16 13:09:56 +02:00
|
|
|
@lst = compile( "while(call(arg > 1)) ; arg = 1 ; end" ).to_vool
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
def test_class
|
|
|
|
assert_equal Vool::WhileStatement , @lst.class
|
|
|
|
assert_equal Vool::LocalAssignment , @lst.body.class
|
|
|
|
end
|
|
|
|
def test_condition_class
|
2019-08-16 13:09:56 +02:00
|
|
|
assert_equal Vool::SendStatement , @lst.condition.class
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
def test_hoist
|
2019-08-16 13:09:56 +02:00
|
|
|
assert_equal Vool::Statements , @lst.hoisted.class
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
2019-08-16 13:09:56 +02:00
|
|
|
def test_hoist_is_assi
|
|
|
|
assert_equal Vool::LocalAssignment , @lst.hoisted.first.class
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|