Add test code

This commit is contained in:
2024-12-11 16:26:57 -05:00
parent 3d17813eb4
commit b013ba0e55
6 changed files with 135 additions and 0 deletions

43
test/arith.w12 Normal file
View File

@ -0,0 +1,43 @@
fn factorial(n: int) -> int {
var result: int;
if n == 0 {
result = 1;
} else {
result = n * factorial(n - 1);
}
return result;
}
fn is_positive(n: int) -> bool {
return n > 0;
}
fn main() -> int {
var a: int = 5;
printf("a = %d\n", a);
var b: int = 3;
printf("b = %d\n", b);
var c: int = (a + b) * 2 - 1;
c += factorial(5);
printf("c = %d\n", c);
while c > 0 {
printf("c = %d\n", c);
if c > 50 {
printf("c is greater than 50\n");
} else {
printf("c is less than or equal to 50\n");
}
c -= 16;
}
printf("End result: %d\n", c);
return 0;
}