]> git.saurik.com Git - bison.git/blobdiff - tests/input.at
xml: match DOT output and xml2dot.xsl processing
[bison.git] / tests / input.at
index 50c1050603615392028fe3764f9e2b4e1f1e5d91..35812c807be1c4b4114d8c8d208ae3dd9ee9724e 100644 (file)
@@ -20,6 +20,67 @@ 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: error: invalid character: '\0'
+input.y:1.1: error: invalid character: '\001'
+input.y:1.1: error: invalid character: '\002'
+input.y:1.1: error: invalid character: '\377'
+input.y:1.2: error: invalid character: '?'
+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.  ##
 ## ------------ ##
@@ -693,9 +754,9 @@ start: DECIMAL_1 HEXADECIMAL_2;
 
 AT_BISON_CHECK([redecl.y], [1], [],
 [[redecl.y:10.10-22: error: user token number 11259375 redeclaration for HEXADECIMAL_1
-redecl.y:9.8-16:   previous declaration for DECIMAL_1
+redecl.y:9.8-16:       previous declaration for DECIMAL_1
 redecl.y:12.10-18: error: user token number 16702650 redeclaration for DECIMAL_2
-redecl.y:11.10-22: previous declaration for HEXADECIMAL_2
+redecl.y:11.10-22:     previous declaration for HEXADECIMAL_2
 ]])
 
 AT_DATA_GRAMMAR([too-large.y],
@@ -1195,7 +1256,7 @@ AT_DATA([empty.y],
 start: '';
 start: '
 ]])
-AT_CHECK([[perl -e "print 'start: \'';" >> empty.y || exit 77]])
+AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]])
 
 AT_BISON_CHECK([empty.y], [1], [],
 [[empty.y:2.8-9: warning: empty character literal
@@ -1210,7 +1271,7 @@ AT_DATA([two.y],
 start: 'ab';
 start: 'ab
 ]])
-AT_CHECK([[perl -e "print 'start: \'ab';" >> two.y || exit 77]])
+AT_CHECK([[$PERL -e "print 'start: \'ab';" >> two.y || exit 77]])
 
 AT_BISON_CHECK([two.y], [1], [],
 [[two.y:2.8-11: warning: extra characters in character literal
@@ -1225,7 +1286,7 @@ AT_DATA([three.y],
 start: 'abc';
 start: 'abc
 ]])
-AT_CHECK([[perl -e "print 'start: \'abc';" >> three.y || exit 77]])
+AT_CHECK([[$PERL -e "print 'start: \'abc';" >> three.y || exit 77]])
 
 AT_BISON_CHECK([three.y], [1], [],
 [[three.y:2.8-12: warning: extra characters in character literal
@@ -1254,7 +1315,7 @@ start: '\777' '\0' '\xfff' '\x0'
 # Beside we cannot even expect "echo '\0'" to output two characters
 # (well three with \n): at least Bash 3.2 converts the two-character
 # sequence "\0" into a single NUL character.
-AT_CHECK([[perl -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
+AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
            || exit 77]])
 
 AT_BISON_CHECK([input.y], [1], [],