rubyx/test/ruby/test_if_statement.rb
Torsten Rüger fd8a3e9cc5 some cc driven cleanup
bit anoying that the builtin engine is used
Even it is not as well configurable as preferred reek.
Still, found one minor bug
2019-10-02 17:54:42 +03:00

46 lines
1.1 KiB
Ruby

require_relative 'helper'
module Ruby
class TestIfStatement < MiniTest::Test
include RubyTests
def basic_if
"if(10 < 12) ; true ; end"
end
def test_if_basic
lst = compile( basic_if )
assert_equal IfStatement , lst.class
end
def test_if_basic_cond
lst = compile( basic_if )
assert_equal ScopeStatement , lst.condition.class
end
def test_if_basic_branches
lst = compile( basic_if )
assert_equal TrueConstant , lst.if_true.class
assert_nil lst.if_false
end
def double_if
"if(false) ; true ; else ; false; end"
end
def test_if_double
lst = compile( double_if )
assert_equal IfStatement , lst.class
end
def test_if_double_cond
lst = compile( double_if )
assert_equal ScopeStatement , lst.condition.class
end
def test_if_double_branches
lst = compile( double_if )
assert_equal TrueConstant , lst.if_true.class
assert_equal FalseConstant, lst.if_false.class
end
def test_to_s
lst = compile( double_if )
assert_tos "if(false);true;else;false;end" , lst
end
end
end