Added test cases for at-expressions.
[voodoo-lang.git] / test / if.voo
blob0d14c9be51cedbaa56ac0694bfded15a6ab4666d
1 #### Test program for conditionals
3 section data
4 different:
5 string "%d is different from %d\n\x00"
7 equal:
8 string "%d is equal to %d\n\x00"
10 greater:
11 string "%d is greater than %d\n\x00"
13 greater_or_equal:
14 string "%d is greater than or equal to %d\n\x00"
16 less:
17 string "%d is less than %d\n\x00"
19 less_or_equal:
20 string "%d is less than or equal to %d\n\x00"
22 nonzero:
23 string "%d is nonzero\n\x00"
25 zero:
26 string "%d is zero\n\x00"
28 section functions
29 import printf
30 export main
32 main:
33 function argc argv
34   let x 0
35   let y 1
37   ifeq x 0
38     call printf zero x
39   else
40     call printf nonzero x
41   end if
43   ifeq y 0
44     call printf zero y
45   else
46     call printf nonzero y
47   end if
49   ifgt x y
50     call printf greater x y
51   else
52     call printf less_or_equal x y
53   end if
55   ifgt y x
56     call printf greater y x
57   else
58     call printf less_or_equal y x
59   end if
61   iflt x y
62     call printf less x y
63   else
64     call printf greater_or_equal x y
65   end if
67   iflt y x
68     call printf less y x
69   else
70     call printf greater_or_equal y x
71   end if
73   set y -1
75   ifne y 0
76     call printf nonzero y
77   else
78     call printf zero y
79   end if
81   ifne x 0
82     call printf nonzero x
83   else
84     call printf zero x
85   end if
87   ifle y x
88     call printf less_or_equal y x
89   else
90     call printf greater y x
91   end if
93   ifle x y
94     call printf less_or_equal x y
95   else
96     call printf greater x y
97   end if
99   ifge x y
100     call printf greater_or_equal x y
101   else
102     call printf less x y
103   end if
105   ifge y x
106     call printf greater_or_equal y x
107   else
108     call printf less y x
109   end if
111   return 0
112 end function