1 # Checking skeleton support. -*- Autotest -*-
2 # Copyright (C) 2007 Free Software Foundation, Inc.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 AT_BANNER([[Skeleton Support.]])
19 ## ------------------------------ ##
20 ## Relative skeleton file names. ##
21 ## ------------------------------ ##
23 AT_SETUP([[Relative skeleton file names]])
25 AT_CHECK([[mkdir tmp]])
27 AT_DATA([[tmp/skel.c]],
28 [[m4@&t@_divert_push(0)d@&t@nl
29 @output(b4_parser_file_name@)d@&t@nl
30 b4_percent_define_get([[test]])
35 [[m4@&t@_divert_push(0)d@&t@nl
36 @output(b4_parser_file_name@)d@&t@nl
37 b4_percent_define_get([[test]]) -- Local
41 AT_DATA([[tmp/input-gram.y]],
42 [[%skeleton "./skel.c"
43 %define test "Hello World"
48 AT_DATA([[input-gram.y]],
49 [[%skeleton "./skel.c"
50 %define test "Hello World"
55 AT_DATA([[tmp/input-cmd-line.y]],
56 [[%define test "Hello World"
61 AT_CHECK([[bison tmp/input-gram.y]])
62 AT_CHECK([[cat input-gram.tab.c]], [[0]],
66 AT_CHECK([[bison input-gram.y]])
67 AT_CHECK([[cat input-gram.tab.c]], [[0]],
68 [[Hello World -- Local
71 AT_CHECK([[bison --skeleton=tmp/skel.c tmp/input-cmd-line.y]])
72 AT_CHECK([[cat input-cmd-line.tab.c]], [[0]],
79 ## ------------------------------- ##
80 ## Installed skeleton file names. ##
81 ## ------------------------------- ##
83 AT_SETUP([[Installed skeleton file names]])
88 void yyerror (char const *msg);
102 yyerror (char const *msg)
104 fprintf (stderr, "%s\n", msg);
120 AT_DATA([[input-cmd-line.y]],
123 AT_DATA([[input-gram.y]],
124 [[%skeleton "yacc.c"]
127 AT_CHECK([[bison --skeleton=yacc.c -o input-cmd-line.c input-cmd-line.y]])
128 AT_COMPILE([[input-cmd-line]])
129 AT_PARSER_CHECK([[./input-cmd-line]], [[1]], [],
130 [[syntax error, unexpected 'a', expecting $end
133 AT_CHECK([[bison -o input-gram.c input-gram.y]])
134 AT_COMPILE([[input-gram]])
135 AT_PARSER_CHECK([[./input-gram]], [[1]], [],
136 [[syntax error, unexpected 'a', expecting $end
144 ## ------------------------------------------------------ ##
145 ## %define Boolean variables: invalid skeleton defaults. ##
146 ## ------------------------------------------------------ ##
148 AT_SETUP([[%define Boolean variables: invalid skeleton defaults]])
150 AT_CHECK([[mkdir tmp]])
153 [[b4_percent_define_default([[foo]], [[bogus value]])
154 b4_percent_define_flag_if([[foo]])
158 [[%skeleton "./skel.c"
163 AT_CHECK([[bison input.y]], [[1]], [[]],
164 [[[Bison:b4_percent_define_default]:0.0: invalid value for %define Boolean variable `foo'