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 )
|
|
|
|
if( n <= 1 )
|
|
|
|
return n
|
|
|
|
else
|
|
|
|
int tmp
|
|
|
|
tmp = n - 1
|
|
|
|
int a = fibonaccir( tmp )
|
|
|
|
tmp = n - 2
|
|
|
|
int b = fibonaccir( tmp )
|
|
|
|
return a + b
|
|
|
|
end
|
|
|
|
end
|
2015-10-07 09:04:55 +02:00
|
|
|
int fib_print(int n)
|
|
|
|
int fib = fibonaccir( n )
|
|
|
|
fib.putint()
|
|
|
|
end
|
2015-10-05 23:27:13 +02:00
|
|
|
int main()
|
|
|
|
fib_print(10)
|
2015-09-20 15:52:26 +02:00
|
|
|
end
|
|
|
|
end
|
2014-05-27 14:31:31 +02:00
|
|
|
HERE
|
2015-10-18 16:39:35 +02:00
|
|
|
@expect = [[SaveReturn,Register::GetSlot,Virtual::Set,Virtual::Set,
|
2015-10-18 16:32:32 +02:00
|
|
|
Virtual::Set,Virtual::Set,Virtual::MethodCall] , [RegisterTransfer,GetSlot,FunctionReturn]]
|
2015-07-19 12:31:13 +02:00
|
|
|
check
|
2014-05-27 14:31:31 +02:00
|
|
|
end
|
|
|
|
end
|