2014-05-28 15:03:54 +03:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
class TestWhileFragment < MiniTest::Test
|
|
|
|
include Fragments
|
|
|
|
|
2014-06-03 22:16:57 +03:00
|
|
|
def test_while_fibo
|
2014-05-28 15:03:54 +03:00
|
|
|
@string_input = <<HERE
|
2015-10-06 00:27:13 +03:00
|
|
|
class Object
|
|
|
|
int fibonaccit(int n)
|
2015-10-27 11:00:48 +02:00
|
|
|
int a = 0
|
|
|
|
int b = 1
|
|
|
|
while_plus( n )
|
|
|
|
int tmp = a
|
|
|
|
a = b
|
|
|
|
b = tmp + b
|
|
|
|
n = n - 1
|
|
|
|
end
|
|
|
|
b.putint()
|
|
|
|
return b
|
2015-10-06 00:27:13 +03:00
|
|
|
end
|
2014-06-07 23:22:32 +03:00
|
|
|
|
2015-10-06 00:27:13 +03:00
|
|
|
int main()
|
|
|
|
fibonaccit( 10 )
|
|
|
|
end
|
|
|
|
end
|
2014-05-28 15:03:54 +03:00
|
|
|
HERE
|
2015-10-27 11:00:48 +02:00
|
|
|
@length = 5
|
2015-07-19 13:31:13 +03:00
|
|
|
check
|
2014-05-28 15:03:54 +03:00
|
|
|
end
|
2014-06-05 16:27:25 +03:00
|
|
|
|
2014-05-28 15:03:54 +03:00
|
|
|
end
|