]>
Commit | Line | Data |
---|---|---|
a7867f53 JD |
1 | # Checking skeleton support. -*- Autotest -*- |
2 | # Copyright (C) 2007 Free Software Foundation, Inc. | |
3 | ||
f16b0819 | 4 | # This program is free software: you can redistribute it and/or modify |
a7867f53 | 5 | # it under the terms of the GNU General Public License as published by |
f16b0819 PE |
6 | # the Free Software Foundation, either version 3 of the License, or |
7 | # (at your option) any later version. | |
8 | # | |
a7867f53 JD |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
f16b0819 | 13 | # |
a7867f53 | 14 | # You should have received a copy of the GNU General Public License |
f16b0819 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
a7867f53 | 16 | |
3eb82471 | 17 | AT_BANNER([[Skeleton Support.]]) |
a7867f53 JD |
18 | |
19 | ## ------------------------------ ## | |
9611cfa2 | 20 | ## Relative skeleton file names. ## |
a7867f53 JD |
21 | ## ------------------------------ ## |
22 | ||
9611cfa2 | 23 | AT_SETUP([[Relative skeleton file names]]) |
a7867f53 JD |
24 | |
25 | AT_CHECK([[mkdir tmp]]) | |
26 | ||
27 | AT_DATA([[tmp/skel.c]], | |
28 | [[m4@&t@_divert_push(0)d@&t@nl | |
29 | @output(b4_parser_file_name@)d@&t@nl | |
30 | b4_percent_define_get([[test]]) | |
31 | m4@&t@_divert_pop(0) | |
32 | ]]) | |
33 | ||
34 | AT_DATA([[skel.c]], | |
35 | [[m4@&t@_divert_push(0)d@&t@nl | |
36 | @output(b4_parser_file_name@)d@&t@nl | |
37 | b4_percent_define_get([[test]]) -- Local | |
38 | m4@&t@_divert_pop(0) | |
39 | ]]) | |
40 | ||
41 | AT_DATA([[tmp/input-gram.y]], | |
42 | [[%skeleton "./skel.c" | |
43 | %define test "Hello World" | |
44 | %% | |
45 | start: ; | |
46 | ]]) | |
47 | ||
48 | AT_DATA([[input-gram.y]], | |
49 | [[%skeleton "./skel.c" | |
50 | %define test "Hello World" | |
51 | %% | |
52 | start: ; | |
53 | ]]) | |
54 | ||
55 | AT_DATA([[tmp/input-cmd-line.y]], | |
56 | [[%define test "Hello World" | |
57 | %% | |
58 | start: ; | |
59 | ]]) | |
60 | ||
da730230 | 61 | AT_BISON_CHECK([[tmp/input-gram.y]]) |
a7867f53 JD |
62 | AT_CHECK([[cat input-gram.tab.c]], [[0]], |
63 | [[Hello World | |
64 | ]]) | |
65 | ||
da730230 | 66 | AT_BISON_CHECK([[input-gram.y]]) |
a7867f53 JD |
67 | AT_CHECK([[cat input-gram.tab.c]], [[0]], |
68 | [[Hello World -- Local | |
69 | ]]) | |
70 | ||
da730230 | 71 | AT_BISON_CHECK([[--skeleton=tmp/skel.c tmp/input-cmd-line.y]]) |
a7867f53 JD |
72 | AT_CHECK([[cat input-cmd-line.tab.c]], [[0]], |
73 | [[Hello World | |
74 | ]]) | |
75 | ||
76 | AT_CLEANUP | |
77 | ||
78 | ||
3eb82471 | 79 | ## ------------------------------- ## |
9611cfa2 | 80 | ## Installed skeleton file names. ## |
3eb82471 | 81 | ## ------------------------------- ## |
a7867f53 | 82 | |
9611cfa2 | 83 | AT_SETUP([[Installed skeleton file names]]) |
a7867f53 JD |
84 | |
85 | m4_pushdef([AT_GRAM], | |
86 | [[%{ | |
87 | #include <stdio.h> | |
88 | void yyerror (char const *msg); | |
89 | int yylex (void); | |
90 | %} | |
91 | ||
92 | %error-verbose | |
93 | %token 'a' | |
94 | ||
95 | %% | |
96 | ||
97 | start: ; | |
98 | ||
99 | %% | |
100 | ||
101 | void | |
102 | yyerror (char const *msg) | |
103 | { | |
104 | fprintf (stderr, "%s\n", msg); | |
105 | } | |
106 | ||
107 | int | |
108 | yylex (void) | |
109 | { | |
110 | return 'a'; | |
111 | } | |
112 | ||
113 | int | |
114 | main (void) | |
115 | { | |
116 | return yyparse (); | |
117 | } | |
118 | ]]) | |
119 | ||
120 | AT_DATA([[input-cmd-line.y]], | |
121 | [AT_GRAM]) | |
122 | ||
123 | AT_DATA([[input-gram.y]], | |
124 | [[%skeleton "yacc.c"] | |
125 | AT_GRAM]) | |
126 | ||
da730230 | 127 | AT_BISON_CHECK([[--skeleton=yacc.c -o input-cmd-line.c input-cmd-line.y]]) |
a7867f53 JD |
128 | AT_COMPILE([[input-cmd-line]]) |
129 | AT_PARSER_CHECK([[./input-cmd-line]], [[1]], [], | |
130 | [[syntax error, unexpected 'a', expecting $end | |
131 | ]]) | |
132 | ||
da730230 | 133 | AT_BISON_CHECK([[-o input-gram.c input-gram.y]]) |
a7867f53 JD |
134 | AT_COMPILE([[input-gram]]) |
135 | AT_PARSER_CHECK([[./input-gram]], [[1]], [], | |
136 | [[syntax error, unexpected 'a', expecting $end | |
137 | ]]) | |
138 | ||
139 | m4_popdef([AT_GRAM]) | |
140 | ||
141 | AT_CLEANUP | |
9611cfa2 JD |
142 | |
143 | ||
144 | ## ------------------------------------------------------ ## | |
922bdd7f | 145 | ## %define Boolean variables: invalid skeleton defaults. ## |
9611cfa2 JD |
146 | ## ------------------------------------------------------ ## |
147 | ||
922bdd7f | 148 | AT_SETUP([[%define Boolean variables: invalid skeleton defaults]]) |
9611cfa2 | 149 | |
9611cfa2 JD |
150 | AT_DATA([[skel.c]], |
151 | [[b4_percent_define_default([[foo]], [[bogus value]]) | |
152 | b4_percent_define_flag_if([[foo]]) | |
153 | ]]) | |
154 | ||
155 | AT_DATA([[input.y]], | |
156 | [[%skeleton "./skel.c" | |
157 | %% | |
158 | start: ; | |
159 | ]]) | |
160 | ||
da730230 | 161 | AT_BISON_CHECK([[input.y]], [[1]], [[]], |
35b8730d | 162 | [[[Bison:b4_percent_define_default]:1.0: invalid value for %define Boolean variable `foo' |
9611cfa2 JD |
163 | ]]) |
164 | ||
165 | AT_CLEANUP | |
166 | ||
167 | ||
7dc4a694 JD |
168 | ## --------------------------------------------- ## |
169 | ## Complaining during macro argument expansion. ## | |
170 | ## --------------------------------------------- ## | |
171 | ||
172 | AT_SETUP([[Complaining during macro argument expansion]]) | |
173 | ||
174 | AT_DATA([[skel1.c]], | |
175 | [[m4@&t@_define([foow], [b4_warn([[foow fubar]])]) | |
176 | m4@&t@_define([foowat], [b4_warn_at([[foow.y:2.3]], | |
177 | [[foow.y:5.4]], [[foowat fubar]])]) | |
178 | m4@&t@_define([fooc], [b4_complain([[fooc fubar]])]) | |
179 | m4@&t@_define([foocat], [b4_complain_at([[fooc.y:1.1]], | |
180 | [[fooc.y:10.6]], [[foocat fubar]])]) | |
181 | m4@&t@_define([foof], [b4_fatal([[foof fubar]])]) | |
182 | m4@&t@_if(foow, [1], [yes]) | |
183 | m4@&t@_if(foowat, [1], [yes]) | |
184 | m4@&t@_if(fooc, [1], [yes]) | |
185 | m4@&t@_if(foocat, [1], [yes]) | |
186 | m4@&t@_if(foof, [1], [yes]) | |
187 | ]]) | |
188 | ||
189 | AT_DATA([[input1.y]], | |
190 | [[%skeleton "./skel1.c" | |
191 | %% | |
192 | start: ; | |
193 | ]]) | |
194 | ||
da730230 | 195 | AT_BISON_CHECK([[input1.y]], [[1]], [[]], |
7dc4a694 JD |
196 | [[input1.y: warning: foow fubar |
197 | foow.y:2.3-5.3: warning: foowat fubar | |
198 | input1.y: fooc fubar | |
199 | fooc.y:1.1-10.5: foocat fubar | |
200 | input1.y: fatal error: foof fubar | |
201 | ]]) | |
202 | ||
203 | AT_DATA([[skel2.c]], | |
204 | [[m4@&t@_define([foofat], [b4_fatal_at([[foof.y:12.11]], | |
205 | [[foof.y:100.123]], [[foofat fubar]])]) | |
206 | m4@&t@_if(foofat, [1], [yes]) | |
207 | ]]) | |
208 | ||
209 | AT_DATA([[input2.y]], | |
210 | [[%skeleton "./skel2.c" | |
211 | %% | |
212 | start: ; | |
213 | ]]) | |
214 | ||
da730230 | 215 | AT_BISON_CHECK([[input2.y]], [[1]], [[]], |
7dc4a694 JD |
216 | [[foof.y:12.11-100.122: fatal error: foofat fubar |
217 | ]]) | |
218 | ||
35b8730d JD |
219 | AT_DATA([[skel3.c]], |
220 | [[b4_complain_at(b4_percent_define_get_loc([[bogus]]), [[bad value]]) | |
221 | ]]) | |
222 | ||
223 | AT_DATA([[input3.y]], | |
224 | [[%skeleton "./skel3.c" | |
225 | %% | |
226 | start: ; | |
227 | ]]) | |
228 | ||
da730230 | 229 | AT_BISON_CHECK([[input3.y]], [[1]], [[]], |
35b8730d JD |
230 | [[input3.y: fatal error: undefined %define variable `bogus' passed to b4_percent_define_get_loc |
231 | ]]) | |
232 | ||
233 | AT_DATA([[skel4.c]], | |
234 | [[b4_warn_at(b4_percent_define_get_syncline([[bogus]]), [[bad value]]) | |
235 | ]]) | |
236 | ||
237 | AT_DATA([[input4.y]], | |
238 | [[%skeleton "./skel4.c" | |
239 | %% | |
240 | start: ; | |
241 | ]]) | |
242 | ||
da730230 | 243 | AT_BISON_CHECK([[input4.y]], [[1]], [[]], |
35b8730d JD |
244 | [[input4.y: fatal error: undefined %define variable `bogus' passed to b4_percent_define_get_syncline |
245 | ]]) | |
246 | ||
7dc4a694 JD |
247 | AT_CLEANUP |
248 | ||
249 | ||
250 | ## --------------------------------------- ## | |
251 | ## Fatal errors make M4 exit immediately. ## | |
252 | ## --------------------------------------- ## | |
253 | ||
254 | AT_SETUP([[Fatal errors make M4 exit immediately]]) | |
255 | ||
256 | AT_DATA([[skel1.c]], | |
257 | [[b4_complain([[non-fatal error]]) | |
258 | b4_fatal([[M4 should exit immediately here]]) | |
259 | m4@&t@_fatal([this should never be evaluated]) | |
260 | ]]) | |
261 | ||
262 | AT_DATA([[input1.y]], | |
263 | [[%skeleton "./skel1.c" | |
264 | %% | |
265 | start: ; | |
266 | ]]) | |
267 | ||
da730230 | 268 | AT_BISON_CHECK([[input1.y]], [[1]], [[]], |
7dc4a694 JD |
269 | [[input1.y: non-fatal error |
270 | input1.y: fatal error: M4 should exit immediately here | |
271 | ]]) | |
272 | ||
273 | AT_DATA([[skel2.c]], | |
274 | [[b4_warn([[morning]]) | |
275 | b4_fatal_at([[foo.y:1.5]], [[foo.y:1.7]], [[M4 should exit immediately here]]) | |
276 | m4@&t@_fatal([this should never be evaluated]) | |
277 | ]]) | |
278 | ||
279 | AT_DATA([[input2.y]], | |
280 | [[%skeleton "./skel2.c" | |
281 | %% | |
282 | start: ; | |
283 | ]]) | |
284 | ||
da730230 | 285 | AT_BISON_CHECK([[input2.y]], [[1]], [[]], |
7dc4a694 JD |
286 | [[input2.y: warning: morning |
287 | foo.y:1.5-6: fatal error: M4 should exit immediately here | |
288 | ]]) | |
289 | ||
290 | AT_CLEANUP |