2018-07-20 16:51:17 +02:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
module Ruby
|
2019-10-03 23:36:49 +02:00
|
|
|
class TestWhileStatementSol < MiniTest::Test
|
2018-07-20 16:51:17 +02:00
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile( "while(@arg) ; @arg = 1 ; end" ).to_sol
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
def test_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::WhileStatement , @lst.class
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
def test_body_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::IvarAssignment , @lst.body.class
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
def test_condition_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::InstanceVariable , @lst.condition.class
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
def test_no_hoist
|
|
|
|
assert_nil @lst.hoisted
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestWhileStatementHoist < MiniTest::Test
|
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile( "while(call(arg > 1)) ; arg = 1 ; end" ).to_sol
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
def test_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::WhileStatement , @lst.class
|
|
|
|
assert_equal Sol::LocalAssignment , @lst.body.class
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
def test_condition_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SendStatement , @lst.condition.class
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
def test_hoist
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::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
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::LocalAssignment , @lst.hoisted.first.class
|
2018-07-20 16:51:17 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|