X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/2a8d363aabf1373d410deb96f5d030ccfed367a6..0f39aab92ab23bc067a3aa102bb56a600c045775:/tests/calc.at diff --git a/tests/calc.at b/tests/calc.at index 82674c10..c3873e57 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -35,15 +35,10 @@ m4_define([_AT_DATA_CALC_Y], [m4_if([$1$2$3], $[1]$[2]$[3], [], [m4_fatal([$0: Invalid arguments: $@])])dnl -AT_DATA([calc.y], +AT_DATA_GRAMMAR([calc.y], [[/* Infix notation calculator--calc */ ]$4[ %{ -#include -/* We don't need perfect functions for these tests. */ -#undef malloc -#undef memcmp -#undef realloc #include #if STDC_HEADERS @@ -100,9 +95,9 @@ static int power (int base, int exponent); /* yyerror receives the location if: - %location & %pure & %glr - %location & %pure & %yacc & %parse-param. */ -static void yyerror (const char *s - ]AT_YYERROR_ARG_LOC_IF([, YYLTYPE *yylloc])[ - ]AT_PARAM_IF([, value_t *result, int *count])[ +static void yyerror (]AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])[ + ]AT_PARAM_IF([value_t *result, int *count, ])[ + const char *s ); static int yylex (LEX_FORMALS); static int yygetc (LEX_FORMALS); @@ -154,10 +149,12 @@ exp: FILE *yyin; static void -yyerror (const char *s - ]AT_YYERROR_ARG_LOC_IF([, YYLTYPE *yylloc])[ - ]AT_PARAM_IF([, value_t *result, int *count])[) +yyerror (]AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])[ + ]AT_PARAM_IF([value_t *result, int *count, ])[ + const char *s + ) { +]AT_PARAM_IF([(void) result; (void) count; ])[ ]AT_YYERROR_SEES_LOC_IF([ fprintf (stderr, "%d.%d-%d.%d: ", LOC.first_line, LOC.first_column, @@ -294,6 +291,7 @@ main (int argc, const char **argv) { value_t result = 0; int count = 0; + int status = 0; yyin = NULL; if (argc == 2) @@ -310,11 +308,10 @@ main (int argc, const char **argv) #if YYDEBUG yydebug = 1; #endif - yyparse (]AT_PARAM_IF([&result, &count])[); + status = yyparse (]AT_PARAM_IF([&result, &count])[); assert (global_result == result); assert (global_count == count); - - return 0; + return status; } ]]) ])# _AT_DATA_CALC_Y @@ -352,9 +349,10 @@ m4_bmatch([$1], ]) -# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, INPUT, [NUM-DEBUG-LINES], +# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, EXIT-STATUS, INPUT, +# [NUM-DEBUG-LINES], # [VERBOSE-AND-LOCATED-ERROR-MESSAGE]) -# ------------------------------------------------------------- +# --------------------------------------------------------- # Run `calc' on INPUT, and expect a `parse error' message. # # If INPUT starts with a slash, it is used as absolute input file name, @@ -370,17 +368,17 @@ m4_bmatch([$1], # If BISON-OPTIONS contains `%debug' but not `%glr', then NUM-STDERR-LINES # is the number of expected lines on stderr. m4_define([_AT_CHECK_CALC_ERROR], -[m4_bmatch([$2], [^/], - [AT_PARSER_CHECK([./calc $2], 0, [], [stderr])], +[m4_bmatch([$3], [^/], + [AT_PARSER_CHECK([./calc $3], $2, [], [stderr])], [AT_DATA([[input]], -[[$2 +[[$3 ]]) -AT_PARSER_CHECK([./calc input], 0, [], [stderr])]) +AT_PARSER_CHECK([./calc input], $2, [], [stderr])]) m4_bmatch([$1], [%debug.*%glr\|%glr.*%debug], [], [%debug], - [AT_CHECK([wc -l