261 |
|
|
262 |
|
|
263 |
|
|
264 |
# _AT_CHECK_CALC(BISON-OPTIONS, INPUT) |
# _AT_CHECK_CALC(BISON-OPTIONS, INPUT, [NUM-STDERR-LINES = 0]) |
265 |
# ------------------------------------ |
# ------------------------------------------------------------ |
266 |
# Run `calc' on INPUT and expect no STDOUT nor STDERR. |
# Run `calc' on INPUT and expect no STDOUT nor STDERR. |
267 |
|
# |
268 |
|
# If BISON-OPTIONS contains `--debug', then NUM-STDERR-LINES is the number |
269 |
|
# of expected lines on stderr. |
270 |
m4_define([_AT_CHECK_CALC], |
m4_define([_AT_CHECK_CALC], |
271 |
[AT_DATA([[input]], |
[AT_DATA([[input]], |
272 |
[[$2 |
[[$2 |
273 |
]]) |
]]) |
274 |
AT_CHECK([calc input])dnl |
AT_CHECK([calc input], 0, [], [stderr])dnl |
275 |
|
AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0, |
276 |
|
[m4_match([$1], [--debug], |
277 |
|
[$3], [0]) |
278 |
|
]) |
279 |
]) |
]) |
280 |
|
|
281 |
|
|
282 |
# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, INPUT, |
# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, INPUT, [NUM-DEBUG-LINES], |
283 |
# [ERROR-LOCATION], [IF-YYERROR-VERBOSE]) |
# [ERROR-LOCATION], [IF-YYERROR-VERBOSE]) |
284 |
# ------------------------------------------------------------ |
# ------------------------------------------------------------ |
285 |
# Run `calc' on INPUT, and expect a `parse error' message. |
# Run `calc' on INPUT, and expect a `parse error' message. |
290 |
# If BISON-OPTIONS contains `--yyerror-verbose', then make sure the |
# If BISON-OPTIONS contains `--yyerror-verbose', then make sure the |
291 |
# IF-YYERROR-VERBOSE message is properly output after `parse error, ' |
# IF-YYERROR-VERBOSE message is properly output after `parse error, ' |
292 |
# on STDERR. |
# on STDERR. |
293 |
|
# |
294 |
|
# If BISON-OPTIONS contains `--debug', then NUM-STDERR-LINES is the number |
295 |
|
# of expected lines on stderr. |
296 |
m4_define([_AT_CHECK_CALC_ERROR], |
m4_define([_AT_CHECK_CALC_ERROR], |
297 |
[AT_DATA([[input]], |
[AT_DATA([[input]], |
298 |
[[$2 |
[[$2 |
299 |
]]) |
]]) |
300 |
|
|
301 |
AT_CHECK([calc input], 0, |
AT_CHECK([calc input], 0, [], [stderr]) |
302 |
[], |
|
303 |
[m4_match([$1], [--location], [$3: ])[]dnl |
|
304 |
|
AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0, |
305 |
|
[m4_match([$1], [--debug], |
306 |
|
[$3], [1]) |
307 |
|
]) |
308 |
|
|
309 |
|
egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr |
310 |
|
mv at-stderr stderr |
311 |
|
|
312 |
|
AT_CHECK([cat stderr], 0, |
313 |
|
[m4_match([$1], [--location], [$4: ])[]dnl |
314 |
parse error[]dnl |
parse error[]dnl |
315 |
m4_match([$1], [--yyerror-verbose], [, $4])[]dnl |
m4_match([$1], [--yyerror-verbose], [, $5])[]dnl |
316 |
|
|
317 |
])]) |
]) |
318 |
|
|
319 |
|
]) |
320 |
|
|
321 |
|
|
322 |
# AT_CHECK_CALC([BISON-OPTIONS], [PARSER-EXPECTED-STDERR]) |
# AT_CHECK_CALC([BISON-OPTIONS], [PARSER-EXPECTED-STDERR]) |
348 |
1 - (2 - 3) = 2 |
1 - (2 - 3) = 2 |
349 |
|
|
350 |
2^2^3 = 256 |
2^2^3 = 256 |
351 |
(2^2)^3 = 64], [$2]) |
(2^2)^3 = 64], [491]) |
352 |
|
|
353 |
# Some parse errors. |
# Some parse errors. |
354 |
_AT_CHECK_CALC_ERROR([$1], [+1], |
_AT_CHECK_CALC_ERROR([$1], [+1], [8], |
355 |
[1.0:1.1], |
[1.0:1.1], |
356 |
[unexpected `'+'']) |
[unexpected `'+'']) |
357 |
_AT_CHECK_CALC_ERROR([$1], [1//2], |
_AT_CHECK_CALC_ERROR([$1], [1//2], [17], |
358 |
[1.2:1.3], |
[1.2:1.3], |
359 |
[unexpected `'/'', expecting `NUM' or `'-'' or `'('']) |
[unexpected `'/'', expecting `NUM' or `'-'' or `'('']) |
360 |
_AT_CHECK_CALC_ERROR([$1], [error], |
_AT_CHECK_CALC_ERROR([$1], [error], [8], |
361 |
[1.0:1.1], |
[1.0:1.1], |
362 |
[unexpected `$undefined.']) |
[unexpected `$undefined.']) |
363 |
_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], |
_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [23], |
364 |
[1.6:1.7], |
[1.6:1.7], |
365 |
[unexpected `'='']) |
[unexpected `'='']) |
366 |
_AT_CHECK_CALC_ERROR([$1], |
_AT_CHECK_CALC_ERROR([$1], |
367 |
[ |
[ |
368 |
+1], |
+1], |
369 |
|
[16], |
370 |
[2.0:2.1], |
[2.0:2.1], |
371 |
[unexpected `'+'']) |
[unexpected `'+'']) |
372 |
|
|