several larger changes came together, bit of cleaning too
- 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
This commit is contained in:
@ -5,20 +5,24 @@ class TestWhileFragment < MiniTest::Test
|
||||
|
||||
def test_while_fibo
|
||||
@string_input = <<HERE
|
||||
int fibonaccit(int n)
|
||||
int a = 0
|
||||
int b = 1
|
||||
while( n > 1 )
|
||||
int tmp = a
|
||||
a = b
|
||||
b = tmp + b
|
||||
n = n - 1
|
||||
end
|
||||
b.putint()
|
||||
return b
|
||||
end
|
||||
class Object
|
||||
int fibonaccit(int n)
|
||||
int a = 0
|
||||
int b = 1
|
||||
while( n > 1 )
|
||||
int tmp = a
|
||||
a = b
|
||||
b = tmp + b
|
||||
n = n - 1
|
||||
end
|
||||
b.putint()
|
||||
return b
|
||||
end
|
||||
|
||||
fibonaccit( 10 )
|
||||
int main()
|
||||
fibonaccit( 10 )
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Virtual::Return ]
|
||||
check
|
||||
|
Reference in New Issue
Block a user