X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/df04a68ab54dcd8b899532c51ed0c8e1a0486296..505ece51710209eb4aba50166f8f7ddc57d0562b:/tests/input.at diff --git a/tests/input.at b/tests/input.at index 16a9308d..cd0dd6ac 100644 --- a/tests/input.at +++ b/tests/input.at @@ -20,6 +20,63 @@ AT_BANNER([[Input Processing.]]) # Mostly test that we are robust to mistakes. +## ---------------- ## +## Invalid inputs. ## +## ---------------- ## + +AT_SETUP([Invalid inputs]) + +AT_DATA([input.y], +[[\000\001\002\377? +%% +? +default: 'a' } +%& +%a-does-not-exist +%- +%{ +]]) +AT_CHECK([[$PERL -pi -e 's/\\(\d{3})/chr(oct($1))/ge' input.y || exit 77]]) + +AT_BISON_CHECK([input.y], [1], [], +[[input.y:1.1-2: error: invalid characters: '\0\001\002\377?' +input.y:3.1: error: invalid character: '?' +input.y:4.14: error: invalid character: '}' +input.y:5.1: error: invalid character: '%' +input.y:5.2: error: invalid character: '&' +input.y:6.1-17: error: invalid directive: '%a-does-not-exist' +input.y:7.1: error: invalid character: '%' +input.y:7.2: error: invalid character: '-' +input.y:8.1-9.0: error: missing '%}' at end of file +input.y:8.1-9.0: error: syntax error, unexpected %{...%} +]]) + +AT_CLEANUP + + +AT_SETUP([Invalid inputs with {}]) + +# We used to SEGV here. See +# http://lists.gnu.org/archive/html/bug-bison/2005-07/msg00053.html + +AT_DATA([input.y], +[[ +%destructor +%initial-action +%lex-param +%parse-param +%printer +%union +]]) + +AT_BISON_CHECK([input.y], [1], [], +[[input.y:3.1-15: error: syntax error, unexpected %initial-action, expecting {...} +]]) + +AT_CLEANUP + + + ## ------------ ## ## Invalid $n. ## ## ------------ ## @@ -756,6 +813,25 @@ input.y:19.13-20.0: error: missing '}' at end of file input.y:20.1: error: syntax error, unexpected end of file ]]) +AT_BISON_CHECK([-fcaret -o input.c input.y], 1, [], +[[input.y:1.10-2.0: error: missing '"' at end of line + %token A "a + ^^ +input.y:4.10-5.0: error: missing "'" at end of line + %token C '1 + ^^ +input.y:14.11-15.0: error: missing "'" at end of line + %type 'a + ^^ +input.y:16.11-17.0: error: missing '"' at end of line + %type "a + ^^ +input.y:19.13-20.0: error: missing '}' at end of file + %destructor { free ($$) + ^^^^^^^^^^^ +input.y:20.1: error: syntax error, unexpected end of file +]]) + AT_CLEANUP @@ -985,6 +1061,18 @@ start: ; ]]) AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [], [[input-dg.y:1.9-11: error: %define variable 'var' redefined +:1: previous definition +]]) + +AT_DATA([[input-dg.y]], +[[%define var "gram" +%% +start: ; +]]) +AT_BISON_CHECK([[-fcaret -Dvar=cmd-d input-dg.y]], [[1]], [], +[[input-dg.y:1.9-11: error: %define variable 'var' redefined + %define var "gram" + ^^^ :2: previous definition ]]) @@ -993,8 +1081,8 @@ AT_DATA([[input-unused.y]], start: ; ]]) AT_BISON_CHECK([[-Dunused-d -Funused-f input-unused.y]], [[1]], [], -[[:2: error: %define variable 'unused-d' is not used -:3: error: %define variable 'unused-f' is not used +[[:1: error: %define variable 'unused-d' is not used +:2: error: %define variable 'unused-f' is not used ]]) AT_CLEANUP @@ -1300,11 +1388,11 @@ start: ; # parse.lac.* options are useless if LAC isn't actually activated. AT_BISON_CHECK([[-Dparse.lac.es-capacity-initial=1 input.y]], [[1]], [], -[[:2: error: %define variable 'parse.lac.es-capacity-initial' is not used +[[:1: error: %define variable 'parse.lac.es-capacity-initial' is not used ]]) AT_BISON_CHECK([[-Dparse.lac.memory-trace=full input.y]], [[1]], [], -[[:2: error: %define variable 'parse.lac.memory-trace' is not used +[[:1: error: %define variable 'parse.lac.memory-trace' is not used ]]) AT_CLEANUP @@ -1363,8 +1451,8 @@ AT_BISON_CHECK([[$2 input.y]], [[1]], [[]], ]) AT_TEST([%define api.prefix foo %name-prefix "bar"], [], [input.y:1.9-18]) -AT_TEST([], [-Dapi.prefix=foo -p bar], [:2]) -AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [:2]) +AT_TEST([], [-Dapi.prefix=foo -p bar], [:1]) +AT_TEST([%name-prefix "bar"], [-Dapi.prefix=foo], [:1]) AT_TEST([%define api.prefix foo], [-p bar], [input.y:1.9-18]) m4_popdef([AT_TEST])