added shared library support to AMD64 and i386
[voodoo-lang.git] / test / mod.voo
blobdf82cb26af178faa8cae7626f1bb2e263e003729
1 #### Test mod action
3 section data
4 format:
5 string "%d\n\x00"
7 section functions
8 import printf
9 export main
11 # Computes x - (x / y * y) - (x % y), which should be zero
12 test_mod:
13 function x y
14     let q div x y
15     let m mod x y
16     let p mul q y
17     let d sub x p
18     return sub d m
19 end function
21 main:
22 function argc argv
23     # Cases where the modulo should be zero
24     let x 24
25     let y mod x 1
26     call printf format y
27     set y mod x -1
28     call printf format y
29     set y mod x 3
30     call printf format y
31     set y mod x -3
32     call printf format y
33     set x -24
34     set y mod x 1
35     call printf format y
36     set y mod x -1
37     call printf format y
38     set y mod x 3
39     call printf format y
40     set y mod x -3
41     call printf format y
43     # Cases where the modulo should be non-zero
44     set y call test_mod 18 5
45     call printf format y
46     set y call test_mod 18 -5
47     call printf format y
48     set y call test_mod -18 5
49     call printf format y
50     set y call test_mod -18 -5
51     call printf format y
53     return 0
54 end function