2014-05-27 15:31:31 +03:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
class TestRecursinveFibo < MiniTest::Test
|
|
|
|
include Fragments
|
|
|
|
|
|
|
|
def test_recursive_fibo
|
|
|
|
@string_input = <<HERE
|
2015-09-20 16:52:26 +03:00
|
|
|
int fib_print(int n)
|
2014-06-08 00:56:40 +03:00
|
|
|
fib = fibonaccir( n )
|
|
|
|
fib.putint()
|
|
|
|
end
|
2015-09-20 16:52:26 +03:00
|
|
|
int fibonaccir( int n )
|
|
|
|
if( n <= 1 )
|
|
|
|
return n
|
|
|
|
else
|
|
|
|
int tmp = n - 1
|
|
|
|
a = fibonaccir( tmp )
|
|
|
|
tmp = n - 2
|
|
|
|
b = fibonaccir( tmp )
|
|
|
|
return a + b
|
|
|
|
end
|
|
|
|
end
|
2014-06-08 00:56:40 +03:00
|
|
|
|
|
|
|
fib_print(10)
|
2014-05-27 15:31:31 +03:00
|
|
|
HERE
|
2015-07-19 13:31:13 +03:00
|
|
|
@expect = [Virtual::Return ]
|
|
|
|
check
|
2014-05-27 15:31:31 +03:00
|
|
|
end
|
|
|
|
end
|