1 # Checking Push Parsing. -*- Autotest -*-
3 # Copyright (C) 2007, 2009-2015, 2018-2020 Free Software Foundation,
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 AT_BANNER([[Push Parsing Tests]])
21 ## -------------------------------- ##
22 ## Memory Leak for Early Deletion. ##
23 ## -------------------------------- ##
25 AT_SETUP([[Memory Leak for Early Deletion]])
28 AT_BISON_OPTION_PUSHDEFS
29 AT_DATA_GRAMMAR([[input.y]],
39 %define api.push-pull push
54 /* Make sure we don't try to free ps->yyss in this case. */
58 /* yypstate_delete used to leak ps->yyss if the stack was reallocated but the
59 parse did not return on success, syntax error, or memory exhaustion. */
61 assert (yypush_parse (ps, 'a', YY_NULLPTR) == YYPUSH_MORE);
65 assert (yypush_parse (ps, 'a', YY_NULLPTR) == YYPUSH_MORE);
66 assert (yypush_parse (ps, 'b', YY_NULLPTR) == YYPUSH_MORE);
72 AT_BISON_OPTION_POPDEFS
74 AT_BISON_CHECK([[-o input.c input.y]])
76 AT_PARSER_CHECK([[input]])
80 ## --------------------------- ##
81 ## Multiple impure instances. ##
82 ## --------------------------- ##
84 AT_SETUP([[Multiple impure instances]])
86 m4_pushdef([AT_MULTIPLE_IMPURE_INSTANCES_CHECK], [
87 AT_BISON_OPTION_PUSHDEFS([%define api.push-pull $1])
88 AT_DATA_GRAMMAR([[input.y]],
94 ]m4_if([$1], [[both]], [AT_YYLEX_DECLARE([])])[
97 %define api.push-pull ]$1[
105 ]m4_if([$1], [[both]], [AT_YYLEX_DEFINE])[
111 for (i = 0; i < 2; ++i)
113 yypstate *ps = yypstate_new ();
115 assert (yypstate_new () == YY_NULLPTR);
116 ]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
118 assert (yypush_parse (ps) == 0);
119 assert (yypstate_new () == YY_NULLPTR);
120 ]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
121 yypstate_delete (ps);
128 AT_BISON_CHECK([[-o input.c input.y]])
129 AT_COMPILE([[input]])
130 AT_PARSER_CHECK([[input]])
131 AT_BISON_OPTION_POPDEFS
134 AT_MULTIPLE_IMPURE_INSTANCES_CHECK([[both]])
135 AT_MULTIPLE_IMPURE_INSTANCES_CHECK([[push]])
137 m4_popdef([AT_MULTIPLE_IMPURE_INSTANCES_CHECK])
141 ## ----------------------- ##
142 ## Unsupported Skeletons. ##
143 ## ----------------------- ##
145 AT_SETUP([[Unsupported Skeletons]])
147 AT_BISON_OPTION_PUSHDEFS
150 %define api.push-pull push
154 AT_BISON_OPTION_POPDEFS
156 AT_BISON_CHECK([[input.y]], [[1]], [],
157 [[input.y:2.1-26: error: %define variable 'api.push-pull' is not used