2014-05-27 14:31:31 +02:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
class TestRecursinveFibo < MiniTest::Test
|
|
|
|
include Fragments
|
|
|
|
|
|
|
|
def test_recursive_fibo
|
|
|
|
@string_input = <<HERE
|
2015-10-07 09:04:55 +02:00
|
|
|
class Object
|
2015-10-05 23:27:13 +02:00
|
|
|
int fibonaccir( int n )
|
2015-11-13 23:22:00 +01:00
|
|
|
if_plus( n - 2 )
|
2015-10-05 23:27:13 +02:00
|
|
|
int tmp
|
|
|
|
tmp = n - 1
|
|
|
|
int a = fibonaccir( tmp )
|
|
|
|
tmp = n - 2
|
|
|
|
int b = fibonaccir( tmp )
|
|
|
|
return a + b
|
2015-10-27 10:00:48 +01:00
|
|
|
else
|
|
|
|
return n
|
2015-10-05 23:27:13 +02:00
|
|
|
end
|
|
|
|
end
|
2015-10-07 09:04:55 +02:00
|
|
|
int fib_print(int n)
|
|
|
|
int fib = fibonaccir( n )
|
|
|
|
fib.putint()
|
2015-11-05 16:00:41 +01:00
|
|
|
return fib
|
2015-10-07 09:04:55 +02:00
|
|
|
end
|
2015-10-05 23:27:13 +02:00
|
|
|
int main()
|
2015-11-10 10:44:55 +01:00
|
|
|
return fib_print(8)
|
2015-09-20 15:52:26 +02:00
|
|
|
end
|
|
|
|
end
|
2014-05-27 14:31:31 +02:00
|
|
|
HERE
|
2015-11-10 10:44:55 +01:00
|
|
|
@length = 2525
|
|
|
|
check_return 21
|
2014-05-27 14:31:31 +02:00
|
|
|
end
|
|
|
|
end
|