X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/aa94def12d5256d2bd3d5ed49d905f00372a0111..5407fc7d76bc0c1d15b0e281ba12ea20c77751e7:/tests/javapush.at diff --git a/tests/javapush.at b/tests/javapush.at index 65027c31..2f710533 100644 --- a/tests/javapush.at +++ b/tests/javapush.at @@ -28,12 +28,13 @@ m4_define([PUSHPULLFLAG],[-Dapi.push-pull=both]) -# Modify the grep tester from java.at -# to ignore status so we can test for zero matching lines +# AT_CHECK_JAVA_GREP(FILE, [LINE], [COUNT=1]) +# ------------------------------------------- +# Check that FILE contains exactly COUNT lines matching ^LINE$ +# with grep. Unquoted so that COUNT can be a shell expression. m4_define([AT_CHECK_JAVA_GREP], - [AT_CHECK([grep -c '^$2$' $1], [ignore], [m4_default([$3], [1]) -]) -]) +[AT_CHECK_UNQUOTED([grep -c '^$2$' $1], [ignore], [m4_default([$3], [1]) +])]) ################################################## @@ -82,7 +83,7 @@ m4_define([AT_TRIVIAL_COMMON],[ } static String[[]] teststatename - = new String[[]]{"YYACCEPT","YYABORT","YYERROR","UNKNOWN","YYMORE"}; + = new String[[]]{"YYACCEPT","YYABORT","YYERROR","UNKNOWN","YYPUSH_MORE"}; static void check(int teststate, int expected, String msg) { @@ -109,16 +110,16 @@ m4_define([AT_TRIVIAL_PARSER],[ setup(); teststate = parser.push_parse('a', null); - check(teststate,YYParser.YYMORE,"push_parse('a', null)"); + check(teststate,YYParser.YYPUSH_MORE,"push_parse('a', null)"); setup(); teststate = parser.push_parse('a', null); - check(teststate,YYParser.YYMORE,"push_parse('a', null)"); + check(teststate,YYParser.YYPUSH_MORE,"push_parse('a', null)"); teststate = parser.push_parse('b', null); - check(teststate,YYParser.YYMORE,"push_parse('b', null)"); + check(teststate,YYParser.YYPUSH_MORE,"push_parse('b', null)"); teststate = parser.push_parse('c', null); - check(teststate,YYParser.YYMORE,"push_parse('c', null)"); + check(teststate,YYParser.YYPUSH_MORE,"push_parse('c', null)"); teststate = parser.push_parse('\0', null); check(teststate,YYParser.YYACCEPT,"push_parse('\\0', null)"); @@ -146,11 +147,11 @@ m4_define([AT_TRIVIAL_PARSER_INITIAL_ACTION],[ setup(); teststate = parser.push_parse('a', null); - check(teststate,YYParser.YYMORE,"push_parse('a', null)"); + check(teststate,YYParser.YYPUSH_MORE,"push_parse('a', null)"); teststate = parser.push_parse('b', null); - check(teststate,YYParser.YYMORE,"push_parse('b', null)"); + check(teststate,YYParser.YYPUSH_MORE,"push_parse('b', null)"); teststate = parser.push_parse('c', null); - check(teststate,YYParser.YYMORE,"push_parse('c', null)"); + check(teststate,YYParser.YYPUSH_MORE,"push_parse('c', null)"); teststate = parser.push_parse('\0', null); check(teststate,YYParser.YYACCEPT,"push_parse('\\0', null)"); @@ -160,43 +161,55 @@ m4_define([AT_TRIVIAL_PARSER_INITIAL_ACTION],[ } ]) +## ----------------------------------------------------- ## +## Trivial Push Parser with api.push-pull verification. ## +## ----------------------------------------------------- ## + AT_SETUP([Trivial Push Parser with api.push-pull verification]) AT_BISON_OPTION_PUSHDEFS -AT_DATA([[input.y]],[[%language "Java" + +AT_DATA([[input.y]], +[[%language "Java" ]AT_TRIVIAL_PARSER[ ]]) -AT_BISON_OPTION_POPDEFS # Verify that the proper procedure(s) are generated for each case. AT_BISON_CHECK([[-Dapi.push-pull=pull -o Main.java input.y]]) AT_CHECK_JAVA_GREP([[Main.java]], [[.*public boolean parse ().*]], [1]) -AT_CHECK_JAVA_GREP( - [[Main.java]], +# If BISON_USE_PUSH_FOR_PULL is set, then we have one occurrence of +# this function, otherwise it should not be there. +AT_CHECK_JAVA_GREP([[Main.java]], [[.*public int push_parse (int yylextoken, Object yylexval).*]], - [0]) + [${BISON_USE_PUSH_FOR_PULL-0}]) + AT_BISON_CHECK([[-Dapi.push-pull=both -o Main.java input.y]]) AT_CHECK_JAVA_GREP([[Main.java]], [[.*public boolean parse ().*]], [1]) -AT_CHECK_JAVA_GREP( - [[Main.java]], +AT_CHECK_JAVA_GREP([[Main.java]], [[.*public int push_parse (int yylextoken, Object yylexval).*]], [1]) + AT_BISON_CHECK([[-Dapi.push-pull=push -o Main.java input.y]]) AT_CHECK_JAVA_GREP([[Main.java]], [[.*public boolean parse ().*]], [0]) -AT_CHECK_JAVA_GREP( - [[Main.java]], +AT_CHECK_JAVA_GREP([[Main.java]], [[.*public int push_parse (int yylextoken, Object yylexval).*]], [1]) AT_JAVA_COMPILE([[Main.java]]) AT_JAVA_PARSER_CHECK([Main], 0, [], [stderr-nolog]) +AT_BISON_OPTION_POPDEFS AT_CLEANUP + +## ------------------------------------------ ## +## Trivial Push Parser with %initial-action. ## +## ------------------------------------------ ## + AT_SETUP([Trivial Push Parser with %initial-action]) AT_BISON_OPTION_PUSHDEFS AT_DATA([[input.y]],[[%language "Java" @@ -575,7 +588,8 @@ AT_JAVA_PARSER_CHECK([Calc input], 0, [ignore-nolog], [stderr-nolog]) # NOTE: because the target is "expout", this macro automatically # compares the output of the sed command with the contents of # the file "expout" (defined above). -AT_CHECK([[sed -e '/^Stack now.*$/p' -e d ./stderr|tee jj]],[ignore],[expout],[ignore-nolog]) +AT_CHECK([[sed -e '/^Stack now.*$/p' -e d ./stderr]], + [ignore], [expout], [ignore-nolog]) AT_BISON_OPTION_POPDEFS AT_CLEANUP