Merge branch 'slimconfigure'
[m6w6/ext-psi] / tests / calc / calc.psi
1 #include <stdlib.h>
2
3 function test\calc1() : array {
4 let numerator = 3 * 5 + 2;
5 let denominator = 17;
6 return div(numerator, denominator) as to_array(div,
7 to_int(quot),
8 to_int(rem)
9 );
10 }
11
12 function test\calc2() : array {
13 let numerator = 4 + 5 * 2;
14 let denominator = 14;
15 return div(numerator, denominator) as to_array(div,
16 to_int(quot),
17 to_int(rem)
18 );
19 }
20
21 function test\calc3() : array {
22 let numerator = -1 + 2 - 3 * 2;
23 let denominator = -5;
24 return div(numerator, denominator) as to_array(div,
25 to_int(quot),
26 to_int(rem)
27 );
28 }
29
30 function test\calc4() : array {
31 let numerator = 1 * 5 / 5 * -1 / -1 * 10 / 5 + 4 * 2;
32 let denominator = 10;
33 return div(numerator, denominator) as to_array(div,
34 to_int(quot),
35 to_int(rem)
36 );
37 }
38
39 function test\calc5() : array {
40 let numerator = 5 % 3;
41 let denominator = 2;
42 return div(numerator, denominator) as to_array(div,
43 to_int(quot),
44 to_int(rem)
45 );
46 }
47
48 function test\calc6() : array {
49 let numerator = 5 % 3 + 1;
50 let denominator = 3;
51 return div(numerator, denominator) as to_array(div,
52 to_int(quot),
53 to_int(rem)
54 );
55 }
56
57 function test\calc7() : array {
58 let numerator = 5 % (3 + 1);
59 let denominator = 1;
60 return div(numerator, denominator) as to_array(div,
61 to_int(quot),
62 to_int(rem)
63 );
64 }
65
66 function test\calc8() : array {
67 let numerator = !0 + !0 + !0;
68 let denominator = 3;
69 return div(numerator, denominator) as to_array(div,
70 to_int(quot),
71 to_int(rem)
72 );
73 }
74
75 function test\calc9() : array {
76 let numerator = 1 && 2;
77 let denominator = 1;
78 return div(numerator, denominator) as to_array(div,
79 to_int(quot),
80 to_int(rem)
81 );
82 }
83
84 function test\calc10() : array {
85 let numerator = (1 | 2 | 4) & ~3;
86 let denominator = 4;
87 return div(numerator, denominator) as to_array(div,
88 to_int(quot),
89 to_int(rem)
90 );
91 }
92
93 function test\calc11() : array {
94 let numerator = 1 + (1 + 1 < 2);
95 let denominator = 1;
96 return div(numerator, denominator) as to_array(div,
97 to_int(quot),
98 to_int(rem)
99 );
100 }
101
102 function test\calc12() : array {
103 let numerator = 1 + (1 + 1 < 3);
104 let denominator = 2;
105 return div(numerator, denominator) as to_array(div,
106 to_int(quot),
107 to_int(rem)
108 );
109 }