f4a4ccb98e
- all code must be in functions (which must be in classes). — changes a fair few tests — also changes api, as method is not recursive, not passed around - all state in instance vars in compiler (no accessors) - class is another such variable, surely more coming all green again
43 lines
556 B
Ruby
43 lines
556 B
Ruby
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::Return ]
|
|
check
|
|
|
|
end
|
|
end
|