mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Moved test_sum into it's own directory under scripts/
This commit is contained in:
17
scripts/test_sum/test_sum.toy
Normal file
17
scripts/test_sum/test_sum.toy
Normal file
@@ -0,0 +1,17 @@
|
||||
//the test case (toy)
|
||||
fn test_sum(key: int, val: int) {
|
||||
fn sum(n: int) {
|
||||
if (n < 2) {
|
||||
return n;
|
||||
}
|
||||
|
||||
return n + sum(n - 1);
|
||||
}
|
||||
|
||||
var result: int const = sum(val);
|
||||
print string key + ": " + string result;
|
||||
}
|
||||
|
||||
for (var i: int = 0; i <= 10; i++) {
|
||||
test_sum(i, i * 1000);
|
||||
}
|
||||
Reference in New Issue
Block a user