| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Before `make install' is performed this script should be runnable with |
|
2
|
|
|
|
|
|
|
# `make test'. After `make install' it should work as `perl test.pl' |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
######################### We start with some black magic to print on failure. |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Change 1..1 below to 1..last_test_to_print . |
|
7
|
|
|
|
|
|
|
# (It may become useful if the test is moved to ./t subdirectory.) |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { $| = 1; print "1..19\n"; } |
|
10
|
|
|
|
|
|
|
END {print "not ok 1\n" unless $loaded;} |
|
11
|
|
|
|
|
|
|
use HTML::Macro; |
|
12
|
|
|
|
|
|
|
$loaded = 1; |
|
13
|
|
|
|
|
|
|
print "ok 1\n"; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
######################### End of black magic. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Insert your test code below (better if it prints "ok 13" |
|
18
|
|
|
|
|
|
|
# (correspondingly "not ok 13") depending on the success of chunk 13 |
|
19
|
|
|
|
|
|
|
# of the test code): |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$ifp = HTML::Macro->new(); |
|
22
|
|
|
|
|
|
|
$ifp->set ('@precompile', 1); |
|
23
|
|
|
|
|
|
|
$result = $ifp->process ('test/test1.html'); |
|
24
|
|
|
|
|
|
|
if ($result eq 'ok') |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
|
|
|
|
|
|
print "ok 1a\n"; |
|
27
|
|
|
|
|
|
|
} else |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
|
|
|
|
|
|
print "not ok 1a: $result\nshould be: ok\n"; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$ifp = HTML::Macro->new(); |
|
34
|
|
|
|
|
|
|
$ifp->declare ('var', 'missing', 'outer'); |
|
35
|
|
|
|
|
|
|
$ifp->set ('var', 'value'); |
|
36
|
|
|
|
|
|
|
$ifp->set ('qvar', '""'); |
|
37
|
|
|
|
|
|
|
$ifp->set ('var_var', 'value2'); |
|
38
|
|
|
|
|
|
|
$ifp->set ('var_UP', 'value3'); |
|
39
|
|
|
|
|
|
|
$result = $ifp->process ('test/test.html'); |
|
40
|
|
|
|
|
|
|
if ($result eq 'value "<quote me>" value2 value_x ##VAR_UP##') |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
|
|
|
|
|
|
print "ok 2\n"; |
|
43
|
|
|
|
|
|
|
} else |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
|
|
|
|
|
|
print "not ok 2: $result\n"; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$ifp = HTML::Macro->new(); |
|
49
|
|
|
|
|
|
|
$ifp->set ('val', 1); |
|
50
|
|
|
|
|
|
|
$result = $ifp->process ('test/test2.html'); |
|
51
|
|
|
|
|
|
|
if ($result eq "greater\ngreaterequal\ngreaterequal\ngreater\ngreater\ngreaterequal\ngreaterequal\ngreater\nok\n") |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
|
|
|
|
|
|
print "ok 3\n"; |
|
54
|
|
|
|
|
|
|
} else |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
|
|
|
|
|
|
print "not ok 3: $result\n"; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$ifp = HTML::Macro->new(); |
|
60
|
|
|
|
|
|
|
$ifp->set ('val', 1); |
|
61
|
|
|
|
|
|
|
$ifp->set ('yes', 1); |
|
62
|
|
|
|
|
|
|
$result = $ifp->process ('test/test3.html'); |
|
63
|
|
|
|
|
|
|
if ($result eq "greater\nlessequal\n") |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
|
|
|
|
|
|
print "ok 4\n"; |
|
66
|
|
|
|
|
|
|
} else |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
|
|
|
|
|
|
print "not ok 4: $result\n"; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$ifp = HTML::Macro->new(); |
|
72
|
|
|
|
|
|
|
$ifp->set ('pagenum', 2); |
|
73
|
|
|
|
|
|
|
$ifp->set ('val', 2); |
|
74
|
|
|
|
|
|
|
$result = $ifp->process ('test/test4.html'); |
|
75
|
|
|
|
|
|
|
if ($result eq "2greater\ngreaterequal\ngreaterequal\ngreater\ngreater\ngreaterequal\ngreaterequal\ngreater\nok\n\ngreater\ngreaterequal\ngreaterequal\ngreater\ngreater\ngreaterequal\ngreaterequal\ngreater\nok\n") |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
|
|
|
|
|
|
print "ok 5\n"; |
|
78
|
|
|
|
|
|
|
} else |
|
79
|
|
|
|
|
|
|
{ |
|
80
|
|
|
|
|
|
|
print "not ok 5: $result\n"; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$ifp = HTML::Macro->new(); |
|
84
|
|
|
|
|
|
|
$ifp->set ('pagenum', 2); |
|
85
|
|
|
|
|
|
|
$ifp->set ('val', 2); |
|
86
|
|
|
|
|
|
|
$result = $ifp->process ('test/test5.html'); |
|
87
|
|
|
|
|
|
|
if ($result eq 'greateroutput should have the quote tag in it #VAL#') |
|
88
|
|
|
|
|
|
|
{ |
|
89
|
|
|
|
|
|
|
print "ok 6\n"; |
|
90
|
|
|
|
|
|
|
} else |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
|
|
|
|
|
|
print "not ok 6: $result\n"; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$ifp = HTML::Macro->new(); |
|
96
|
|
|
|
|
|
|
$ifp->push_incpath ('test/include'); |
|
97
|
|
|
|
|
|
|
$result = $ifp->process ('test/test6.html'); |
|
98
|
|
|
|
|
|
|
if ($result eq 'included file stuff.htmlincluded file substuff.html 6a') |
|
99
|
|
|
|
|
|
|
{ |
|
100
|
|
|
|
|
|
|
print "ok 7\n"; |
|
101
|
|
|
|
|
|
|
} else |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
|
|
|
|
|
|
print "not ok 7: $result\n"; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$ifp->set ('@collapse_whitespace', 1); |
|
107
|
|
|
|
|
|
|
$result = $ifp->process ('test/test7.html'); |
|
108
|
|
|
|
|
|
|
if ($result eq "This has extra white space end ") |
|
109
|
|
|
|
|
|
|
{ |
|
110
|
|
|
|
|
|
|
print "ok 8\n"; |
|
111
|
|
|
|
|
|
|
} else |
|
112
|
|
|
|
|
|
|
{ |
|
113
|
|
|
|
|
|
|
print "not ok 8: $result\n"; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$ifp->set ('@collapse_whitespace', 0); |
|
117
|
|
|
|
|
|
|
$ifp->set ('@collapse_blank_lines', 1); |
|
118
|
|
|
|
|
|
|
$result = $ifp->process ('test/test7.html'); |
|
119
|
|
|
|
|
|
|
if ($result eq "This has extra\n white space\n\nend\n") |
|
120
|
|
|
|
|
|
|
{ |
|
121
|
|
|
|
|
|
|
print "ok 9\n"; |
|
122
|
|
|
|
|
|
|
} else |
|
123
|
|
|
|
|
|
|
{ |
|
124
|
|
|
|
|
|
|
print "not ok 9: $result\nshould be:This has extra\n white space\n\nend\n"; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub set_val_to_world |
|
128
|
|
|
|
|
|
|
{ |
|
129
|
|
|
|
|
|
|
my ($htm) = @_; |
|
130
|
|
|
|
|
|
|
$htm->set ('val', 'World'); |
|
131
|
|
|
|
|
|
|
return $htm->process; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub set_val_to_world_no_nest |
|
135
|
|
|
|
|
|
|
{ |
|
136
|
|
|
|
|
|
|
my ($htm) = @_; |
|
137
|
|
|
|
|
|
|
$htm->set ('val', 'World'); |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
$result = $ifp->process ('test/test-eval.html'); |
|
141
|
|
|
|
|
|
|
if ($result eq "Hello, World!\n" x 7) |
|
142
|
|
|
|
|
|
|
{ |
|
143
|
|
|
|
|
|
|
print "ok 10\n"; |
|
144
|
|
|
|
|
|
|
} else |
|
145
|
|
|
|
|
|
|
{ |
|
146
|
|
|
|
|
|
|
print "not ok 10:\n$result\nshould be:\n", ("Hello, World!\n" x 6); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
$ifp->set_global ('val', -1); |
|
150
|
|
|
|
|
|
|
$ifp->set ('yes', 1); |
|
151
|
|
|
|
|
|
|
$result = $ifp->process ('test/test-global.html'); |
|
152
|
|
|
|
|
|
|
if ($result eq "greater\nlessequal\n") |
|
153
|
|
|
|
|
|
|
{ |
|
154
|
|
|
|
|
|
|
print "ok 11\n"; |
|
155
|
|
|
|
|
|
|
} else |
|
156
|
|
|
|
|
|
|
{ |
|
157
|
|
|
|
|
|
|
print "not ok 11: $result\n"; |
|
158
|
|
|
|
|
|
|
print "val=", $ifp->get ('val'), "\n"; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
$ifp->set_ovalue ('val', -1); |
|
162
|
|
|
|
|
|
|
$ifp->set_ovalue ('oval', 1); |
|
163
|
|
|
|
|
|
|
$result = $ifp->process ('test/test-global.html'); |
|
164
|
|
|
|
|
|
|
if ($result eq "lessequal\ngreater\n") |
|
165
|
|
|
|
|
|
|
{ |
|
166
|
|
|
|
|
|
|
print "ok 12\n"; |
|
167
|
|
|
|
|
|
|
} else |
|
168
|
|
|
|
|
|
|
{ |
|
169
|
|
|
|
|
|
|
print "not ok 12: $result\n"; |
|
170
|
|
|
|
|
|
|
print "ovalues=", keys %{$ifp->{'@ovalues'}}, "\n"; |
|
171
|
|
|
|
|
|
|
print "val=", $ifp->get ('val'), "\n"; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
if (grep /oval/, $ifp->keys()) { |
|
175
|
|
|
|
|
|
|
print "ok 13\n"; |
|
176
|
|
|
|
|
|
|
} else { |
|
177
|
|
|
|
|
|
|
print "not ok 13: keys does not contain oval\n"; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
eval { |
|
181
|
|
|
|
|
|
|
$ifp->process ('test/test-error.txt'); |
|
182
|
|
|
|
|
|
|
}; |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
if ($@ =~ qr{^HTML::Macro: error parsing 'if' attributes: blah |
|
185
|
|
|
|
|
|
|
parsing .*test-error.txt on line 3, char 0 |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
; the error should be at char 0 |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
called from test.pl, line }) { |
|
190
|
|
|
|
|
|
|
print "ok 14\n"; |
|
191
|
|
|
|
|
|
|
} else { |
|
192
|
|
|
|
|
|
|
print "not ok 14: error handler produced $@\n"; |
|
193
|
|
|
|
|
|
|
print "should be: ", q{HTML::Macro: error parsing 'if' attributes: blah |
|
194
|
|
|
|
|
|
|
parsing .*/test-error.txt on line 3, char 0 |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
; the error should be at char 0 |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
called from test.pl, line }; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
$ifp = new HTML::Macro; |
|
202
|
|
|
|
|
|
|
$result = $ifp->process ('test/test-elsif.html'); |
|
203
|
|
|
|
|
|
|
if ($result ne "one\ntwo\nthree\nfour\n") { |
|
204
|
|
|
|
|
|
|
print "not ok 15: test-elsif produced $result\n"; |
|
205
|
|
|
|
|
|
|
} else { |
|
206
|
|
|
|
|
|
|
print "ok 15\n"; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
$ifp = new HTML::Macro; |
|
210
|
|
|
|
|
|
|
$ifp->set ('yes', 1); |
|
211
|
|
|
|
|
|
|
$result = $ifp->process ('test/test-def-global.html'); |
|
212
|
|
|
|
|
|
|
if ($result eq "greater\nlessequal\n") |
|
213
|
|
|
|
|
|
|
{ |
|
214
|
|
|
|
|
|
|
print "ok 16\n"; |
|
215
|
|
|
|
|
|
|
} else |
|
216
|
|
|
|
|
|
|
{ |
|
217
|
|
|
|
|
|
|
print "not ok 16: $result\n"; |
|
218
|
|
|
|
|
|
|
print "val=", $ifp->get ('val'), "\n"; |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
$ifp = new HTML::Macro; |
|
222
|
|
|
|
|
|
|
$result = $ifp->process ('test/test-include-body.html'); |
|
223
|
|
|
|
|
|
|
if ($result eq "included: BODY") |
|
224
|
|
|
|
|
|
|
{ |
|
225
|
|
|
|
|
|
|
print "ok 17\n"; |
|
226
|
|
|
|
|
|
|
} else |
|
227
|
|
|
|
|
|
|
{ |
|
228
|
|
|
|
|
|
|
print "not ok 17: $result\n"; |
|
229
|
|
|
|
|
|
|
} |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
$result = $ifp->process ('test/test-include-body2.html'); |
|
232
|
|
|
|
|
|
|
if ($result eq "BODY") |
|
233
|
|
|
|
|
|
|
{ |
|
234
|
|
|
|
|
|
|
print "ok 18\n"; |
|
235
|
|
|
|
|
|
|
} else |
|
236
|
|
|
|
|
|
|
{ |
|
237
|
|
|
|
|
|
|
print "not ok 18: $result\n"; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
$result = $ifp->process ('test/test-include-body3.html'); |
|
241
|
|
|
|
|
|
|
if ($result eq "BODY") |
|
242
|
|
|
|
|
|
|
{ |
|
243
|
|
|
|
|
|
|
print "ok 19\n"; |
|
244
|
|
|
|
|
|
|
} else |
|
245
|
|
|
|
|
|
|
{ |
|
246
|
|
|
|
|
|
|
print "not ok 19: $result\n"; |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
$result = $ifp->process_buf ('ok'); |
|
250
|
|
|
|
|
|
|
if ($result eq "ok") |
|
251
|
|
|
|
|
|
|
{ |
|
252
|
|
|
|
|
|
|
print "ok 20\n"; |
|
253
|
|
|
|
|
|
|
} else |
|
254
|
|
|
|
|
|
|
{ |
|
255
|
|
|
|
|
|
|
print "not ok 20: $result\n"; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
$result = $ifp->process_buf ('ok#ok#'); |
|
259
|
|
|
|
|
|
|
if ($result eq "ok") |
|
260
|
|
|
|
|
|
|
{ |
|
261
|
|
|
|
|
|
|
print "ok 21\n"; |
|
262
|
|
|
|
|
|
|
} else |
|
263
|
|
|
|
|
|
|
{ |
|
264
|
|
|
|
|
|
|
print "not ok 21: $result\n"; |
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
$result = $ifp->process_buf (q{ |
|
268
|
|
|
|
|
|
|
ok |
|
269
|
|
|
|
|
|
|
#ok1# |
|
270
|
|
|
|
|
|
|
#ok1# #ok2# |
|
271
|
|
|
|
|
|
|
}); |
|
272
|
|
|
|
|
|
|
if ($result =~ /ok ok/) |
|
273
|
|
|
|
|
|
|
{ |
|
274
|
|
|
|
|
|
|
print "ok 22\n"; |
|
275
|
|
|
|
|
|
|
} else |
|
276
|
|
|
|
|
|
|
{ |
|
277
|
|
|
|
|
|
|
print "not ok 22: $result\n"; |
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
$result = $ifp->process_buf (q{ |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
#ok1# |
|
283
|
|
|
|
|
|
|
#ok1# #ok2# |
|
284
|
|
|
|
|
|
|
}); |
|
285
|
|
|
|
|
|
|
if ($result =~ /ok ok/) |
|
286
|
|
|
|
|
|
|
{ |
|
287
|
|
|
|
|
|
|
print "ok 23\n"; |
|
288
|
|
|
|
|
|
|
} else |
|
289
|
|
|
|
|
|
|
{ |
|
290
|
|
|
|
|
|
|
print "not ok 23: $result\n"; |
|
291
|
|
|
|
|
|
|
} |
|
292
|
|
|
|
|
|
|
|