m4: Sync with FreeBSD.
[dragonfly.git] / usr.bin / m4 / TEST / math.m4
1 dnl $FreeBSD: src/usr.bin/m4/TEST/math.m4,v 1.2 2012/11/17 01:54:24 svnexp Exp $
2 dnl A regression test for m4 C operators                (ksb,petef)
3 dnl If you think you have a short-circuiting m4, run us m4 -DSHORCIRCUIT=yes
4 dnl
5 dnl first level of precedence
6 ifelse(expr(-7),-7,,`failed -
7 ')dnl
8 ifelse(expr(- -2),2,,`failed -
9 ')dnl
10 ifelse(expr(!0),1,,`failed !
11 ')dnl
12 ifelse(expr(!7),0,,`failed !
13 ')dnl
14 ifelse(expr(~-1),0,,`failed ~
15 ')dnl
16 dnl next level of precedence
17 ifelse(expr(3*5),15,,`failed *
18 ')dnl
19 ifelse(expr(3*0),0,,`failed *
20 ')dnl
21 ifelse(expr(11/2),5,,`failed /
22 ')dnl
23 ifelse(expr(1/700),0,,`failed /
24 ')dnl
25 ifelse(expr(10%5),0,,`failed %
26 ')dnl
27 ifelse(expr(2%5),2,,`failed %
28 ')dnl
29 ifelse(expr(2%-1),0,,`failed %
30 ')dnl
31 dnl next level of precedence
32 ifelse(expr(2+2),4,,`failed +
33 ')dnl
34 ifelse(expr(2+-2),0,,`failed +
35 ')dnl
36 ifelse(expr(2- -2),4,,`failed -
37 ')dnl
38 ifelse(expr(2-2),0,,`failed -
39 ')dnl
40 dnl next level of precedence
41 ifelse(expr(1<<4),16,,`failed <<
42 ')dnl
43 ifelse(expr(16>>4),1,,`failed >>
44 ')dnl
45 dnl next level of precedence
46 ifelse(expr(4<4),0,,`failed <
47 ')dnl
48 ifelse(expr(4<5),1,,`failed <
49 ')dnl
50 ifelse(expr(4<3),0,,`failed <
51 ')dnl
52 ifelse(expr(4>4),0,,`failed >
53 ')dnl
54 ifelse(expr(4>5),0,,`failed >
55 ')dnl
56 ifelse(expr(4>3),1,,`failed >
57 ')dnl
58 ifelse(expr(4<=4),1,,`failed <=
59 ')dnl
60 ifelse(expr(4<=5),1,,`failed <=
61 ')dnl
62 ifelse(expr(4<=3),0,,`failed <=
63 ')dnl
64 ifelse(expr(4>=4),1,,`failed >=
65 ')dnl
66 ifelse(expr(4>=5),0,,`failed >=
67 ')dnl
68 ifelse(expr(4>=3),1,,`failed >=
69 ')dnl
70 dnl next level of precedence
71 ifelse(expr(1==1),1,,`failed ==
72 ')dnl
73 ifelse(expr(1==-1),0,,`failed ==
74 ')dnl
75 ifelse(expr(1!=1),0,,`failed !=
76 ')dnl
77 ifelse(expr(1!=2),1,,`failed !=
78 ')dnl
79 dnl next level of precedence
80 ifelse(expr(3&5),1,,`failed &
81 ')dnl
82 ifelse(expr(8&7),0,,`failed &
83 ')dnl
84 dnl next level of precedence
85 ifelse(expr(1^1),0,,`failed ^
86 ')dnl
87 ifelse(expr(21^5),16,,`failed ^
88 ')dnl
89 dnl next level of precedence
90 ifelse(expr(1|1),1,,`failed |
91 ')dnl
92 ifelse(expr(21|5),21,,`failed |
93 ')dnl
94 ifelse(expr(100|1),101,,`failed |
95 ')dnl
96 dnl next level of precedence
97 ifelse(expr(1&&1),1,,`failed &&
98 ')dnl
99 ifelse(expr(0&&1),0,,`failed &&
100 ')dnl
101 ifelse(expr(1&&0),0,,`failed &&
102 ')dnl
103 ifelse(SHORTCIRCUIT,`yes',`ifelse(expr(0&&10/0),0,,`failed && shortcircuit
104 ')')dnl
105 dnl next level of precedence
106 ifelse(expr(1||1),1,,`failed ||
107 ')dnl
108 ifelse(expr(1||0),1,,`failed ||
109 ')dnl
110 ifelse(expr(0||0),0,,`failed ||
111 ')dnl
112 ifelse(SHORTCIRCUIT,`yes',`ifelse(expr(1||10/0),1,,`failed || shortcircuit
113 ')')dnl
114 dnl next level of precedence
115 ifelse(expr(0 ? 2 : 5),5,,`failed ?:
116 ')dnl
117 ifelse(expr(1 ? 2 : 5),2,,`failed ?:
118 ')dnl
119 ifelse(SHORTCIRCUIT,`yes',`ifelse(expr(0 ? 10/0 : 7),7,,`failed ?: shortcircuit
120 ')')dnl
121 ifelse(SHORTCIRCUIT,`yes',`ifelse(expr(1 ? 7 : 10/0),7,,`failed ?: shortcircuit
122 ')')dnl
123 dnl operator precedence
124 ifelse(expr(!0*-2),-2,,`precedence wrong, ! *
125 ')dnl
126 ifelse(expr(~8/~2),3,,`precedence wrong ~ /
127 ')dnl
128 ifelse(expr(~-20%7),5,,`precedence wrong ~ %
129 ')dnl
130 ifelse(expr(3*2+100),106,,`precedence wrong * +
131 ')dnl
132 ifelse(expr(3+2*100),203,,`precedence wrong + *
133 ')dnl
134 ifelse(expr(2%5-6/3),0,,`precedence wrong % -
135 ')dnl
136 ifelse(expr(2/5-5%3),-2,,`precedence wrong / -
137 ')dnl
138 ifelse(expr(2+5%5+1),3,,`precedence wrong % +
139 ')dnl
140 ifelse(expr(7+9<<1),32,,`precedence wrong + <<
141 ')dnl
142 ifelse(expr(35-3>>2),8,,`precedence wrong - >>
143 ')dnl
144 ifelse(expr(9<10<<5),1,,`precedence wrong << <
145 ')dnl
146 ifelse(expr(9>10<<5),0,,`precedence wrong << >
147 ')dnl
148 ifelse(expr(32>>2<32),1,,`precedence wrong >> <
149 ')dnl
150 ifelse(expr(9<=10<<5),1,,`precedence wrong << <
151 ')dnl
152 ifelse(expr(5<<1<=20>>1),1,,`precedence wrong << <=
153 ')dnl
154 ifelse(expr(5<<1>=20>>1),1,,`precedence wrong << >=
155 ')dnl
156 ifelse(expr(0<7==5>=5),1,,`precedence wrong < ==
157 ')dnl
158 ifelse(expr(0<7!=5>=5),0,,`precedence wrong < !=
159 ')dnl
160 ifelse(expr(0>7==5>=5),0,,`precedence wrong > ==
161 ')dnl
162 ifelse(expr(0>7!=5>=5),1,,`precedence wrong > !=
163 ')dnl
164 ifelse(expr(1&7==7),1,,`precedence wrong & ==
165 ')dnl
166 ifelse(expr(0&7!=6),0,,`precedence wrong & !=
167 ')dnl
168 ifelse(expr(9&1|5),5,,`precedence wrong & |
169 ')dnl
170 ifelse(expr(9&1^5),4,,`precedence wrong & ^
171 ')dnl
172 ifelse(expr(9^1|5),13,,`precedence wrong ^ |
173 ')dnl
174 ifelse(expr(5|0&&1),1,,`precedence wrong | &&
175 ')dnl
176 ifelse(expr(5&&0||0&&5||5),1,,`precedence wrong && ||
177 ')dnl
178 ifelse(expr(0 || 1 ? 0 : 1),0,,`precedence wrong || ?:
179 ')dnl
180 ifelse(expr(5&&(0||0)&&(5||5)),0,,`precedence wrong || parens
181 ')dnl