rubyx/test/compiler/fragments/test_while_fibo.rb

45 lines
753 B
Ruby
Raw Normal View History

require_relative 'helper'
class TestWhileFragment < MiniTest::Test
include Fragments
2015-11-06 13:24:57 +01:00
def fibo num
@string_input = <<HERE
class Object
int fibonaccit(int n)
2015-10-27 10:00:48 +01:00
int a = 0
int b = 1
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
end
2014-06-07 22:22:32 +02:00
int main()
2015-11-06 13:24:57 +01:00
return fibonaccit( 100 )
end
end
HERE
2015-11-06 13:24:57 +01:00
@string_input.sub!( "100" , num.to_s )
end
def test_while_fibo94
fibo 91
@length = 2138
# this is not the correct fibo, just what comes from wrapping (smaller than below)
check_return 48360591948142405
2015-11-06 13:24:57 +01:00
end
def test_while_fibo90
fibo 90
@length = 2115
check_return 2880067194370816120
end
2014-06-05 15:27:25 +02:00
end