2020-03-26 19:30:47 +01:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Mains
|
|
|
|
class WhileTester < MiniTest::Test
|
|
|
|
include MainsHelper
|
|
|
|
|
2020-03-27 18:04:10 +01:00
|
|
|
def test_while_cmp
|
2020-03-26 19:30:47 +01:00
|
|
|
@preload = "Integer.gt;Integer.plus"
|
|
|
|
@input = as_main 'a = -1; while( 0 > a); a = 1 + a;end;return a'
|
|
|
|
assert_result 0 , ""
|
|
|
|
end
|
2020-03-27 18:04:10 +01:00
|
|
|
|
|
|
|
def test_while_count
|
|
|
|
@preload = "Integer.gt;Integer.plus"
|
|
|
|
@input = as_main 'a = -1; while( 0 > a); a = 1 + a;end;return a'
|
|
|
|
assert_result 0 , ""
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_while_simple
|
|
|
|
@input = as_main 'a = true; while( a ); a = false;end;return a'
|
|
|
|
# assert_result 4 , ""
|
|
|
|
end
|
|
|
|
|
2020-03-26 19:30:47 +01:00
|
|
|
end
|
|
|
|
end
|