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