rubyx/test/vool/statements/test_while_statement.rb

40 lines
1.0 KiB
Ruby
Raw Normal View History

2017-04-03 10:49:21 +02:00
require_relative 'helper'
module Vool
class TestWhileStatement < MiniTest::Test
def basic_while
"while(10 < 12) ; true ; end"
end
def test_while_basic
lst = RubyCompiler.compile( basic_while )
2017-04-03 10:49:21 +02:00
assert_equal WhileStatement , lst.class
end
def test_while_basic_cond
lst = RubyCompiler.compile( basic_while )
2017-04-03 10:49:21 +02:00
assert_equal SendStatement , lst.condition.class
end
def test_while_basic_branches
lst = RubyCompiler.compile( basic_while )
2017-04-03 10:49:21 +02:00
assert_equal TrueStatement , lst.statements.class
end
def reverse_while
"true while(false)"
end
def test_while_reverse_branches
lst = RubyCompiler.compile( reverse_while )
2017-04-03 10:49:21 +02:00
assert_equal WhileStatement , lst.class
end
def test_while_reverse_cond
lst = RubyCompiler.compile( reverse_while )
2017-04-03 10:49:21 +02:00
assert_equal FalseStatement , lst.condition.class
end
def test_while_reverse_branches
lst = RubyCompiler.compile( reverse_while )
2017-04-03 10:49:21 +02:00
assert_equal TrueStatement , lst.statements.class
end
end
end