rubyx/test/compiler/fragments/test_functions.rb

44 lines
662 B
Ruby
Raw Normal View History

require_relative 'helper'
class TestFunctions < MiniTest::Test
include Fragments
2014-05-28 13:27:18 +02:00
def test_functions
@string_input = <<HERE
class Object
2015-09-20 15:30:07 +02:00
int minus(int a,int b)
return a - b
end
2015-09-20 15:30:07 +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
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
int main()
t_seven()
end
end
HERE
2015-10-10 11:04:34 +02:00
@expect = [[Virtual::MethodEnter,Register::GetSlot,Virtual::Set,Virtual::Set,Virtual::MethodCall] ,
2015-10-09 20:53:22 +02:00
[Virtual::MethodReturn]]
2015-07-19 10:15:38 +02:00
check
end
end