2014-05-24 10:18:54 +03:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
class TestIf < MiniTest::Test
|
|
|
|
include Fragments
|
|
|
|
|
2015-07-18 15:28:57 +03:00
|
|
|
def test_if_basic
|
|
|
|
@string_input = <<HERE
|
|
|
|
if( n < 12)
|
|
|
|
3
|
|
|
|
else
|
|
|
|
4
|
|
|
|
end
|
|
|
|
HERE
|
|
|
|
@expect = [Virtual::Return ]
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-07-19 13:03:21 +03:00
|
|
|
def test_return
|
|
|
|
@string_input = <<HERE
|
|
|
|
return 5
|
|
|
|
HERE
|
|
|
|
@expect = [Virtual::Return ]
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-07-19 13:20:34 +03:00
|
|
|
def test_if_function
|
2014-05-24 10:18:54 +03:00
|
|
|
@string_input = <<HERE
|
2014-05-30 10:42:43 +03:00
|
|
|
def itest(n)
|
2015-07-19 11:15:38 +03:00
|
|
|
if( n < 12)
|
|
|
|
"then".putstring()
|
|
|
|
else
|
|
|
|
"else".putstring()
|
|
|
|
end
|
2014-05-30 10:42:43 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
itest(20)
|
2014-05-24 10:18:54 +03:00
|
|
|
HERE
|
2015-07-18 15:28:57 +03:00
|
|
|
@expect = [Virtual::Return ]
|
|
|
|
check
|
2014-05-24 10:18:54 +03:00
|
|
|
end
|
|
|
|
end
|