]> git.saurik.com Git - bison.git/blame - tests/skeletons.at
Get rid of broken %no-parser, -n, and --no-parser implementation and
[bison.git] / tests / skeletons.at
CommitLineData
a7867f53
JD
1# Checking skeleton support. -*- Autotest -*-
2# Copyright (C) 2007 Free Software Foundation, Inc.
3
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 2, or (at your option)
7# any later version.
8
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.
13
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17# 02110-1301, USA.
18
3eb82471 19AT_BANNER([[Skeleton Support.]])
a7867f53
JD
20
21## ------------------------------ ##
9611cfa2 22## Relative skeleton file names. ##
a7867f53
JD
23## ------------------------------ ##
24
9611cfa2 25AT_SETUP([[Relative skeleton file names]])
a7867f53
JD
26
27AT_CHECK([[mkdir tmp]])
28
29AT_DATA([[tmp/skel.c]],
30[[m4@&t@_divert_push(0)d@&t@nl
31@output(b4_parser_file_name@)d@&t@nl
32b4_percent_define_get([[test]])
33m4@&t@_divert_pop(0)
34]])
35
36AT_DATA([[skel.c]],
37[[m4@&t@_divert_push(0)d@&t@nl
38@output(b4_parser_file_name@)d@&t@nl
39b4_percent_define_get([[test]]) -- Local
40m4@&t@_divert_pop(0)
41]])
42
43AT_DATA([[tmp/input-gram.y]],
44[[%skeleton "./skel.c"
45%define test "Hello World"
46%%
47start: ;
48]])
49
50AT_DATA([[input-gram.y]],
51[[%skeleton "./skel.c"
52%define test "Hello World"
53%%
54start: ;
55]])
56
57AT_DATA([[tmp/input-cmd-line.y]],
58[[%define test "Hello World"
59%%
60start: ;
61]])
62
63AT_CHECK([[bison tmp/input-gram.y]])
64AT_CHECK([[cat input-gram.tab.c]], [[0]],
65[[Hello World
66]])
67
68AT_CHECK([[bison input-gram.y]])
69AT_CHECK([[cat input-gram.tab.c]], [[0]],
70[[Hello World -- Local
71]])
72
73AT_CHECK([[bison --skeleton=tmp/skel.c tmp/input-cmd-line.y]])
74AT_CHECK([[cat input-cmd-line.tab.c]], [[0]],
75[[Hello World
76]])
77
78AT_CLEANUP
79
80
3eb82471 81## ------------------------------- ##
9611cfa2 82## Installed skeleton file names. ##
3eb82471 83## ------------------------------- ##
a7867f53 84
9611cfa2 85AT_SETUP([[Installed skeleton file names]])
a7867f53
JD
86
87m4_pushdef([AT_GRAM],
88[[%{
89 #include <stdio.h>
90 void yyerror (char const *msg);
91 int yylex (void);
92%}
93
94%error-verbose
95%token 'a'
96
97%%
98
99start: ;
100
101%%
102
103void
104yyerror (char const *msg)
105{
106 fprintf (stderr, "%s\n", msg);
107}
108
109int
110yylex (void)
111{
112 return 'a';
113}
114
115int
116main (void)
117{
118 return yyparse ();
119}
120]])
121
122AT_DATA([[input-cmd-line.y]],
123[AT_GRAM])
124
125AT_DATA([[input-gram.y]],
126[[%skeleton "yacc.c"]
127AT_GRAM])
128
129AT_CHECK([[bison --skeleton=yacc.c -o input-cmd-line.c input-cmd-line.y]])
130AT_COMPILE([[input-cmd-line]])
131AT_PARSER_CHECK([[./input-cmd-line]], [[1]], [],
132[[syntax error, unexpected 'a', expecting $end
133]])
134
135AT_CHECK([[bison -o input-gram.c input-gram.y]])
136AT_COMPILE([[input-gram]])
137AT_PARSER_CHECK([[./input-gram]], [[1]], [],
138[[syntax error, unexpected 'a', expecting $end
139]])
140
141m4_popdef([AT_GRAM])
142
143AT_CLEANUP
9611cfa2
JD
144
145
146## ------------------------------------------------------ ##
147## %define boolean variables: invalid skeleton defaults. ##
148## ------------------------------------------------------ ##
149
150AT_SETUP([[%define boolean variables: invalid skeleton defaults]])
151
152AT_CHECK([[mkdir tmp]])
153
154AT_DATA([[skel.c]],
155[[b4_percent_define_default([[foo]], [[bogus value]])
156b4_percent_define_flag_if([[foo]])
157]])
158
159AT_DATA([[input.y]],
160[[%skeleton "./skel.c"
161%%
162start: ;
163]])
164
165AT_CHECK([[bison input.y]], [[1]], [[]],
166[[[Bison:b4_percent_define_default]:0.0: invalid value for %define boolean variable `foo'
167]])
168
169AT_CLEANUP
170
171