2014-05-25 07:43:07 +02:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
class TestFunctions < MiniTest::Test
|
|
|
|
include Fragments
|
|
|
|
|
2014-05-28 13:27:18 +02:00
|
|
|
def test_functions
|
2014-05-25 07:43:07 +02:00
|
|
|
@string_input = <<HERE
|
2015-10-05 23:27:13 +02:00
|
|
|
class Object
|
2015-09-20 15:30:07 +02:00
|
|
|
|
2015-10-05 23:27:13 +02:00
|
|
|
int minus(int a,int b)
|
|
|
|
return a - b
|
|
|
|
end
|
2015-09-20 15:30:07 +02:00
|
|
|
|
2015-10-05 23:27:13 +02:00
|
|
|
int plus(int a, int b)
|
|
|
|
return a + b
|
2015-07-19 10:15:38 +02:00
|
|
|
end
|
2015-09-20 15:30:07 +02:00
|
|
|
|
2015-10-05 23:27:13 +02:00
|
|
|
int times(int a, int b)
|
|
|
|
if( b == 0 )
|
|
|
|
a = 0
|
|
|
|
else
|
|
|
|
int m = minus(b, 1)
|
|
|
|
int t = times(a, m)
|
|
|
|
a = plus(a,t)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
int t_seven()
|
|
|
|
int tim = times(7,6)
|
|
|
|
tim.putint()
|
|
|
|
end
|
2014-06-07 22:22:32 +02:00
|
|
|
|
2015-10-05 23:27:13 +02:00
|
|
|
int main()
|
|
|
|
t_seven()
|
|
|
|
end
|
|
|
|
end
|
2014-05-25 07:43:07 +02:00
|
|
|
HERE
|
2015-10-18 18:27:46 +02:00
|
|
|
@expect = [[SaveReturn,Register::GetSlot,Virtual::Set,Virtual::Set,RegisterTransfer,FunctionCall] ,
|
2015-10-18 16:32:32 +02:00
|
|
|
[RegisterTransfer,GetSlot,FunctionReturn]]
|
2015-07-19 10:15:38 +02:00
|
|
|
check
|
|
|
|
|
2014-05-25 07:43:07 +02:00
|
|
|
end
|
|
|
|
end
|