X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/83b60c97ee1f98bb1f15ffa38acdc4cc765515f5..d1cc31c5f04b81a3620fa291020ce23490f3f9e7:/tests/input.at diff --git a/tests/input.at b/tests/input.at index 146d5818..36a6d408 100644 --- a/tests/input.at +++ b/tests/input.at @@ -1055,6 +1055,17 @@ AT_BISON_CHECK([[input.y]], [1], [], [[input.y:1.9-34: invalid value for %define Boolean variable `lr.keep-unreachable-states' ]]) +AT_DATA([[input.y]], +[[%define namespace "foo" +%define api.namespace "foo" +%% +start: ; +]]) +AT_BISON_CHECK([[input.y]], [1], [], +[[input.y:2.9-21: %define variable `api.namespace' redefined +input.y:1.9-17: previous definition +]]) + AT_DATA([[input.y]], [[%define foo_bar "baz" %% @@ -1209,3 +1220,53 @@ three.y:4.8-11: missing `'' at end of file ]]) AT_CLEANUP + +## ------------------------- ## +## Bad escapes in literals. ## +## ------------------------- ## + +AT_SETUP([[Bad escapes in literals]]) + +AT_DATA([input.y], +[[%% +start: '\777' '\0' '\xfff' '\x0' + '\uffff' '\u0000' '\Uffffffff' '\U00000000' + '\ ' '\A'; +]]) + +# It is not easy to create special characters, we can only trust tr. +# 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. +# +# Z for 0, O for 1. +echo 'start: "\T\F\Z\O" ;' | tr 'TFZO' '\011\014\0\1' >> input.y + +AT_BISON_CHECK([input.y], [1], [], +[[input.y:2.9-12: invalid number after \-escape: 777 +input.y:2.8-13: warning: empty character literal +input.y:2.16-17: invalid number after \-escape: 0 +input.y:2.15-18: warning: empty character literal +input.y:2.21-25: invalid number after \-escape: xfff +input.y:2.20-26: warning: empty character literal +input.y:2.29-31: invalid number after \-escape: x0 +input.y:2.28-32: warning: empty character literal +input.y:3.9-14: invalid number after \-escape: uffff +input.y:3.8-15: warning: empty character literal +input.y:3.18-23: invalid number after \-escape: u0000 +input.y:3.17-24: warning: empty character literal +input.y:3.27-36: invalid number after \-escape: Uffffffff +input.y:3.26-37: warning: empty character literal +input.y:3.40-49: invalid number after \-escape: U00000000 +input.y:3.39-50: warning: empty character literal +input.y:4.9-10: invalid character after \-escape: ` ' +input.y:4.8-11: warning: empty character literal +input.y:4.14-15: invalid character after \-escape: A +input.y:4.13-16: warning: empty character literal +input.y:5.9-16: invalid character after \-escape: \t +input.y:5.17: invalid character after \-escape: \f +input.y:5.18: invalid character after \-escape: \0 +input.y:5.19: invalid character after \-escape: \001 +]]) + +AT_CLEANUP