1 # Checking Push Parsing. -*- Autotest -*-
3 # Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 AT_BANNER([[Push Parsing Tests]])
20 ## -------------------------------- ##
21 ## Memory Leak for Early Deletion. ##
22 ## -------------------------------- ##
24 AT_SETUP([[Memory Leak for Early Deletion]])
27 AT_BISON_OPTION_PUSHDEFS
28 AT_DATA_GRAMMAR([[input.y]],
38 %define api.push-pull push
53 /* Make sure we don't try to free ps->yyss in this case. */
57 /* yypstate_delete used to leak ps->yyss if the stack was reallocated but the
58 parse did not return on success, syntax error, or memory exhaustion. */
60 assert (yypush_parse (ps, 'a', YY_NULLPTR) == YYPUSH_MORE);
64 assert (yypush_parse (ps, 'a', YY_NULLPTR) == YYPUSH_MORE);
65 assert (yypush_parse (ps, 'b', YY_NULLPTR) == YYPUSH_MORE);
71 AT_BISON_OPTION_POPDEFS
73 AT_BISON_CHECK([[-o input.c input.y]])
75 AT_PARSER_CHECK([[./input]])
79 ## --------------------------- ##
80 ## Multiple impure instances. ##
81 ## --------------------------- ##
83 AT_SETUP([[Multiple impure instances]])
85 m4_pushdef([AT_MULTIPLE_IMPURE_INSTANCES_CHECK], [
86 AT_BISON_OPTION_PUSHDEFS([%define api.push-pull $1])
87 AT_DATA_GRAMMAR([[input.y]],
93 ]m4_if([$1], [[both]], [AT_YYLEX_DECLARE([])])[
96 %define api.push-pull ]$1[
104 ]m4_if([$1], [[both]], [AT_YYLEX_DEFINE])[
110 for (i = 0; i < 2; ++i)
112 yypstate *ps = yypstate_new ();
114 assert (yypstate_new () == YY_NULLPTR);
115 ]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
117 assert (yypush_parse (ps) == 0);
118 assert (yypstate_new () == YY_NULLPTR);
119 ]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
120 yypstate_delete (ps);
127 AT_BISON_CHECK([[-o input.c input.y]])
128 AT_COMPILE([[input]])
129 AT_PARSER_CHECK([[./input]])
130 AT_BISON_OPTION_POPDEFS
133 AT_MULTIPLE_IMPURE_INSTANCES_CHECK([[both]])
134 AT_MULTIPLE_IMPURE_INSTANCES_CHECK([[push]])
136 m4_popdef([AT_MULTIPLE_IMPURE_INSTANCES_CHECK])
140 ## ----------------------- ##
141 ## Unsupported Skeletons. ##
142 ## ----------------------- ##
144 AT_SETUP([[Unsupported Skeletons]])
146 AT_BISON_OPTION_PUSHDEFS
149 %define api.push-pull push
153 AT_BISON_OPTION_POPDEFS
155 AT_BISON_CHECK([[input.y]], [[1]], [],
156 [[input.y:2.9-21: error: %define variable 'api.push-pull' is not used