2017-04-03 10:49:21 +02:00
|
|
|
require_relative 'helper'
|
|
|
|
|
2018-07-19 13:46:51 +02:00
|
|
|
module Ruby
|
2018-07-07 16:57:46 +02:00
|
|
|
class TestWhileStatementX < MiniTest::Test
|
2018-06-29 21:56:49 +02:00
|
|
|
include RubyTests
|
2017-04-03 10:49:21 +02:00
|
|
|
|
|
|
|
def basic_while
|
|
|
|
"while(10 < 12) ; true ; end"
|
|
|
|
end
|
|
|
|
def test_while_basic
|
2018-06-29 21:56:49 +02:00
|
|
|
lst = compile( basic_while )
|
2017-04-03 10:49:21 +02:00
|
|
|
assert_equal WhileStatement , lst.class
|
|
|
|
end
|
|
|
|
def test_while_basic_cond
|
2018-06-29 21:56:49 +02:00
|
|
|
lst = compile( basic_while )
|
2018-03-16 15:09:35 +01:00
|
|
|
assert_equal ScopeStatement , lst.condition.class
|
2017-04-03 10:49:21 +02:00
|
|
|
end
|
|
|
|
def test_while_basic_branches
|
2018-06-29 21:56:49 +02:00
|
|
|
lst = compile( basic_while )
|
2018-03-16 15:09:35 +01:00
|
|
|
assert_equal TrueConstant , lst.body.class
|
2017-04-03 10:49:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def reverse_while
|
|
|
|
"true while(false)"
|
|
|
|
end
|
|
|
|
def test_while_reverse_branches
|
2018-06-29 21:56:49 +02:00
|
|
|
lst = compile( reverse_while )
|
2017-04-03 10:49:21 +02:00
|
|
|
assert_equal WhileStatement , lst.class
|
|
|
|
end
|
|
|
|
def test_while_reverse_cond
|
2018-06-29 21:56:49 +02:00
|
|
|
lst = compile( reverse_while )
|
2018-03-16 15:09:35 +01:00
|
|
|
assert_equal ScopeStatement , lst.condition.class
|
2017-04-03 10:49:21 +02:00
|
|
|
end
|
|
|
|
def test_while_reverse_branches
|
2018-06-29 21:56:49 +02:00
|
|
|
lst = compile( reverse_while )
|
2018-03-16 15:09:35 +01:00
|
|
|
assert_equal TrueConstant , lst.body.class
|
2017-04-03 10:49:21 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|