Imported Robodoc.
[robodoc.git] / Source / t / headers.t
1 #!perl
2 # vi: spell ff=unix
3 use strict;
4 use warnings;
5 use ROBOTestFrame;
6 use Test::More 'no_plan';
7 use XML::Simple;
8
9 #****h* ROBODoc System Tests/Header Test
10 # FUNCTION
11 #   Tests the parsing of ROBODoc headers.
12 #
13 #*****
14
15 #****x* Header Test/Happy Path
16 # FUNCTION
17 #   Happy Path Simple plain header. This definitely should work
18 # SOURCE
19 #
20 {
21     my $source = <<'EOF';
22 /****f* Test/test
23  * NAME
24  *   Test
25  * FUNCTION
26  *   Test2
27  ******
28  */
29 EOF
30
31     add_source( "test.c", $source );
32     my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --test) );
33     is( $out, '', 'no output' );
34     is( $err, '', 'and no error' );
35     clean();
36 }
37 #*******
38
39
40 #****x* Header Test/Names with Spaces
41 # FUNCTION
42 #   Try a header name with spaces and some '*' at
43 #   the end.  The '*' should be ignored.
44 # SOURCE
45 {
46     my $source = <<'EOF';
47 /****f* Test Foo Bar/Name With Spaces ****
48  * NAME
49  *   Test
50  * FUNCTION
51  *   Test2
52  ******
53  */
54 EOF
55
56     add_source( "test.c", $source );
57     my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --test) );
58     is( $out, '', 'no output' );
59     is( $err, '', 'and no error' );
60     my $documentation = XMLin( 'Doc/test_c.xml' );
61     my $header = $documentation->{'header'};
62     is ( $header->{'name'}, 'Test Foo Bar/Name With Spaces', 'Header name' );
63
64     clean();
65 }
66
67 #*****
68
69 #****x* Header Test/Multiple Names with Spaces
70 # FUNCTION
71 #   Try several header with names that contain spaces.
72 #   These should be accepted.
73 # SOURCE
74 {
75     my $source = <<'EOF';
76 /****f* Test Foo Bar/Name With Spaces, And Anotherone,
77  *                   And One More, More
78  * NAME
79  *   Test
80  * FUNCTION
81  *   Test2
82  ******
83  */
84 EOF
85
86     add_source( "test.c", $source );
87     my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --test) );
88     is( $out, '', 'no output' );
89     is( $err, '', 'and no error' );
90     my $documentation = XMLin( 'Doc/test_c.xml' );
91     my $header = $documentation->{'header'};
92     is ( $header->{'name'}, 'Test Foo Bar/Name With Spaces', 'Header name' );
93
94     clean();
95 }
96
97 #*****
98
99 #****x* Header Test/Broken header
100 # FUNCTION
101 #  Try several header with names that contain spaces.
102 #  These should be accepted.
103 # SOURCE
104 {
105     my $source = <<'EOF';
106 {****f* xxxxxx/x_xxx_xxxxxxxxxxxxxxxxxxxxxxxx
107 *
108 *OMSCHRIJVING
109 *xxxx xxxxxxx xxxxxxxxx xxxxxxxxxx xxxxxxx xxxxxxxxxxxx xx xx
110 xxxxxxxxxxxxxxx
111 *xxxxxxxxx x_xxx_xxxxxxxxxxxxxxxxxx xxxxxxx
112 *
113 *INVOER
114 *xxxxxxx : xxx xxxxxxx xxxx xxxxxx xxxxxxxxx xxxxxxxxxxxx xxxxx xx xxx
115 xx
116 * xxxxxxxxx xxxxxxxxx xxxxx xxxxxxxxxxxx.
117 *xxxxxxxxxxx : xxx xxxxxxxxx xxxxx xxxxx xxx xx xxxxx xxxxxx xx xxxxxxxxxx
118 * xxxxxxxxx xxxxxxxx xx
119 *RETURNWAARDE
120 *xxxx__xxxxxxx, x_xxx_xxxxxxxxx, xxxx__xxxxxxxx, x_xxx_xxxxxxxx,
121 *x_xxx_xxxxxxxxx, x_xxx_xxxxxxxxxxxxxx xx x_xxxx_xxxxxx_xxx
122 xxxxxx xxxxx.
123 *
124 *VOORBEELD
125 *x_xxx_xxxxxxxxxxxxxxxxxxxxxxxx (xxxxxxx := 5000,
126 * xxxxxxxxxxx := xx_xxxxxxxxxxx);
127 *DECLARATIE
128 *}
129
130 {*****}
131 EOF
132
133
134     my $config = <<'EOF';
135 items:
136     OMSCHRIJVING
137     WIJZIGINGSOVERZICHT
138     DECLARATIE
139     INVOER
140     UITVOER
141     IN-UITVOER
142     PARAMETERS
143     BOUNDARIES
144     RETURNWAARDE
145     ATTRIBUTEN
146     GEBRUIKTE GEGEVENS
147     VOORBEELD
148     ZIE VERDER
149     OPMERKINGEN
150     PRECONDITIE
151     POSTCONDITIE 
152
153 item order:
154     OMSCHRIJVING
155     DECLARATIE
156
157 source items:
158     DECLARATIE
159     SOURCE
160     
161 preformatted items:
162     WIJZIGINGSOVERZICHT
163     INVOER
164     UITVOER   
165     IN-UITVOER
166     PARAMETERS
167     RETURNWAARDE
168     ATTRIBUTEN
169     VOORBEELD
170
171 headertypes:
172     h   "Modules"        vptlib_modules
173     f   "Functies"       vptlib_functies
174     v   "Variabelen"     vptlib_variabelen
175     s   "Structuren"     vptlib_structuren
176     e   "Enumeraties"    vptlib_enumeraties
177     c   "Constanten"     vptlib_constanten
178     u   "Unittesten"     vptlib_unittesten
179     t   "Typedefinities" vptlib_typedefs
180     m   "Macros"         vptlib_macros
181     d   "Definities"     vptlib_definities
182
183 options:
184     --documenttitle "Xxxxxxxxxxxxxxxxxxx"
185     --tabsize 8
186     --index 
187     --sections
188     --sectionnameonly  
189     --nopre
190     --multidoc
191  
192 header markers:
193     /****
194     #****
195     !****
196     {****
197
198 remark markers:
199     *
200     #
201     !
202     
203 end markers:
204     ****
205     #****
206     !****
207     {****
208
209 remark begin markers:
210     /*
211     {*
212
213 remark end markers:
214     */
215     *}
216
217 source line comments:
218     //
219     !
220     *
221 EOF
222
223     add_source( "test.c", $source );
224     add_configuration( "test.rc", $config );
225     my ($out, $err) = runrobo( qw(--src Src --doc Doc --rc Config/test.rc --test) );
226     is( $out, '', 'no output' );
227     is( $err, '', 'and no error' );
228
229     clean();
230 }
231
232 #*****
233
234
235
236 #****x* Header Test/Circular header
237 # FUNCTION
238 #   The 3rd header points to the first header, 
239 #   completing a circle.  ROBODoc should complain
240 #   about this.
241
242 # SOURCE
243 TODO: {
244     local $TODO = "checking circular headers is not implemented yet.";
245     my $source = <<'EOF';
246
247 /****f* Foo/Bar
248 * NAME
249 *   Bar
250 ****/
251
252 /****f* Bar/Fii
253  * NAME
254  *   Foo
255  *****/
256
257 /****f* Fii/Bar
258  * NAME
259  *   Foo
260  *****/
261 EOF
262
263     add_source( "test.c", $source );
264     my ($out, $err) = runrobo( qw(
265         --src Src
266         --doc Doc
267         --multidoc
268         --html
269         --toc
270         --sections
271         ) );
272     # ROBODoc should complain about circular 
273     # headers.
274     isnt( $err, '', 'there should be an error' );
275 #    clean();
276 }
277
278 #*****