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