33 lines
432 B
Plaintext
33 lines
432 B
Plaintext
fn fib(int n) int
|
|
{
|
|
if (n <= 1)
|
|
return n;
|
|
|
|
return fib(n - 1) + fib(n - 2);
|
|
}
|
|
|
|
fn sum(uint a, uint b) uint
|
|
{
|
|
return a + b;
|
|
}
|
|
|
|
printline("Test #1: fibonacci");
|
|
int result = fib(7);
|
|
if (result == 13)
|
|
printline("Recurse test passed");
|
|
else
|
|
{
|
|
printline("Recurse test failed");
|
|
exit(1);
|
|
}
|
|
|
|
printline("Test #2: sum");
|
|
if (sum(2, 2) == 4)
|
|
printline("Sum test passed");
|
|
else
|
|
{
|
|
printline("Sum test failed");
|
|
exit(1);
|
|
}
|
|
|