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