X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/51dec47b377d301d4656ee6da5eaafc22604e5a7..c0ad8bf3c2fb46f001bb24ac98a72b8bfb3a77ce:/tests/calc.at diff --git a/tests/calc.at b/tests/calc.at index ddc86464..8875f9cd 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -1,5 +1,5 @@ # Checking the output filenames. -*- Autotest -*- -# Copyright 2000, 2001 Free Software Foundation, Inc. +# Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -61,12 +61,16 @@ static int yygetc (void); static void yyungetc (int c); extern void perror (const char *s); + +/* Exercise pre-prologue dependency to %union. */ +typedef int value_t; + %} -/* Also exercise %union. */ +/* Exercise %union. */ %union { - int ival; /* A comment to exercise an old bug. */ + value_t ival; }; /* Bison Declarations */ @@ -90,8 +94,8 @@ input: ; line: - '\n' -| exp '\n' {} + '\n' {} +| exp '\n' {} ; exp: @@ -286,7 +290,7 @@ m4_define([_AT_CHECK_CALC], [AT_DATA([[input]], [[$2 ]]) -AT_CHECK([./calc input], 0, [], [stderr])dnl +AT_PARSER_CHECK([./calc input], 0, [], [stderr])dnl AT_CHECK([wc -l at-stderr +sed '/^Starting/d +/^Entering/d +/^Reading/d +/^Reducing/d +/^Shifting/d +/^state/d +/^Error:/d +/^Next/d +/^Discarding/d +/^yydestructor:/d' stderr >at-stderr mv at-stderr stderr # 2. Create the reference error message. AT_DATA([[expout]], @@ -359,7 +372,7 @@ AT_DATA_CALC_Y([$1]) AT_CHECK([bison calc.y -o calc.c m4_bpatsubst([$1], [--yyerror-verbose])], [0], [], []) -AT_CHECK([$CC $CFLAGS $CPPFLAGS calc.c -o calc], 0, [], [ignore]) +AT_COMPILE([calc]) # Test the priorities. _AT_CHECK_CALC([$1], @@ -378,41 +391,35 @@ _AT_CHECK_CALC([$1], (2^2)^3 = 64], [486]) # Some parse errors. -_AT_CHECK_CALC_ERROR([$1], [0 0], [10], +_AT_CHECK_CALC_ERROR([$1], [0 0], [11], [1.3-1.4: parse error, unexpected "number"]) -_AT_CHECK_CALC_ERROR([$1], [1//2], [13], +_AT_CHECK_CALC_ERROR([$1], [1//2], [15], [1.3-1.4: parse error, unexpected '/', expecting "number" or '-' or '(']) _AT_CHECK_CALC_ERROR([$1], [error], [4], - [1.1-1.2: parse error, unexpected $undefined., expecting "number" or '-' or '\n' or '(']) -_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [19], + [1.1-1.2: parse error, unexpected $undefined, expecting "number" or '-' or '\n' or '(']) +_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [22], [1.7-1.8: parse error, unexpected '=']) _AT_CHECK_CALC_ERROR([$1], [ +1], - [13], + [14], [2.1-2.2: parse error, unexpected '+']) # Exercise error messages with EOF: work on an empty file. -_AT_CHECK_CALC_ERROR([$1], - [/dev/null], - [4], +_AT_CHECK_CALC_ERROR([$1], [/dev/null], [4], [1.1-1.2: parse error, unexpected "end of file", expecting "number" or '-' or '\n' or '(']) # Exercise the error token: without it, we die at the first error, # hence be sure i. to have several errors, ii. to test the action # associated to `error'. -_AT_CHECK_CALC_ERROR([$1], - [(1 ++ 2) + (0 0) = 1], - [76], +_AT_CHECK_CALC_ERROR([$1], [(1 ++ 2) + (0 0) = 1], [82], [1.5-1.6: parse error, unexpected '+', expecting "number" or '-' or '(' 1.15-1.16: parse error, unexpected "number" calc: error: 0 != 1]) # Add a studid example demonstrating that Bison can further improve the # error message. FIXME: Fix this ridiculous message. -_AT_CHECK_CALC_ERROR([$1], - [()], - [21], -[1.2-1.3: parse error, unexpected ')', expecting error or "number" or '-' or '(']) +_AT_CHECK_CALC_ERROR([$1], [()], [21], +[1.2-1.3: parse error, unexpected ')', expecting "number" or '-' or '(']) AT_CLEANUP ])# AT_CHECK_CALC