clearer organization for compiler tests
was slightly messy with small/large now needed different test for expression and statements
This commit is contained in:
43
test/compiler/fragments/test_functions.rb
Normal file
43
test/compiler/fragments/test_functions.rb
Normal file
@ -0,0 +1,43 @@
|
||||
require_relative 'helper'
|
||||
|
||||
class TestFunctions < MiniTest::Test
|
||||
include Fragments
|
||||
|
||||
def test_functions
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
|
||||
int minus(int a,int b)
|
||||
return a - b
|
||||
end
|
||||
|
||||
int plus(int a, int b)
|
||||
return a + b
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
int main()
|
||||
t_seven()
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [[Virtual::MethodEnter,Register::GetSlot,Virtual::Set,Virtual::Set,Virtual::MethodCall] ,
|
||||
[Virtual::MethodReturn]]
|
||||
check
|
||||
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user