Commit | Line | Data |
724aa791 |
1 | #!perl |
2 | |
3 | BEGIN { |
4 | chdir 't'; |
5 | @INC = ('../lib', '../ext/B/t'); |
9cd8f857 |
6 | require Config; |
7 | if (($Config::Config{'extensions'} !~ /\bB\b/) ){ |
8 | print "1..0 # Skip -- Perl configured without B module\n"; |
9 | exit 0; |
10 | } |
2799c206 |
11 | if ($Config{'extensions'} !~ /\bData\/Dumper\b/) { |
12 | print |
13 | "1..0 # Skip: Data::Dumper was not built, needed by OptreeCheck\n"; |
14 | exit 0; |
15 | |
16 | } |
7252851f |
17 | if ($] < 5.009) { |
18 | print "1..0 # Skip -- TODO - provide golden result regexps for 5.8\n"; |
19 | exit 0; |
20 | } |
724aa791 |
21 | require './test.pl'; |
22 | } |
23 | use OptreeCheck; |
2ce64696 |
24 | use Config; |
cc02ea56 |
25 | plan tests => 20; |
2ce64696 |
26 | SKIP: { |
cc02ea56 |
27 | skip "no perlio in this build", 20 unless $Config::Config{useperlio}; |
724aa791 |
28 | |
29 | pass("GENERAL OPTREE EXAMPLES"); |
30 | |
31 | pass("IF,THEN,ELSE, ?:"); |
32 | |
33 | checkOptree ( name => '-basic sub {if shift print then,else}', |
34 | bcopts => '-basic', |
35 | code => sub { if (shift) { print "then" } |
36 | else { print "else" } |
37 | }, |
38 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
724aa791 |
39 | # 9 <1> leavesub[1 ref] K/REFC,1 ->(end) |
40 | # - <@> lineseq KP ->9 |
41 | # 1 <;> nextstate(main 426 optree.t:16) v ->2 |
42 | # - <1> null K/1 ->- |
43 | # 5 <|> cond_expr(other->6) K/1 ->a |
44 | # 4 <1> shift sK/1 ->5 |
45 | # 3 <1> rv2av[t2] sKRM/1 ->4 |
46 | # 2 <#> gv[*_] s ->3 |
47 | # - <@> scope K ->- |
48 | # - <0> ex-nextstate v ->6 |
49 | # 8 <@> print sK ->9 |
50 | # 6 <0> pushmark s ->7 |
51 | # 7 <$> const[PV "then"] s ->8 |
52 | # f <@> leave KP ->9 |
53 | # a <0> enter ->b |
54 | # b <;> nextstate(main 424 optree.t:17) v ->c |
55 | # e <@> print sK ->f |
56 | # c <0> pushmark s ->d |
57 | # d <$> const[PV "else"] s ->e |
58 | EOT_EOT |
59 | # 9 <1> leavesub[1 ref] K/REFC,1 ->(end) |
60 | # - <@> lineseq KP ->9 |
61 | # 1 <;> nextstate(main 427 optree_samples.t:18) v ->2 |
62 | # - <1> null K/1 ->- |
63 | # 5 <|> cond_expr(other->6) K/1 ->a |
64 | # 4 <1> shift sK/1 ->5 |
65 | # 3 <1> rv2av[t1] sKRM/1 ->4 |
66 | # 2 <$> gv(*_) s ->3 |
67 | # - <@> scope K ->- |
68 | # - <0> ex-nextstate v ->6 |
69 | # 8 <@> print sK ->9 |
70 | # 6 <0> pushmark s ->7 |
71 | # 7 <$> const(PV "then") s ->8 |
72 | # f <@> leave KP ->9 |
73 | # a <0> enter ->b |
74 | # b <;> nextstate(main 425 optree_samples.t:19) v ->c |
75 | # e <@> print sK ->f |
76 | # c <0> pushmark s ->d |
77 | # d <$> const(PV "else") s ->e |
78 | EONT_EONT |
79 | |
80 | checkOptree ( name => '-basic (see above, with my $a = shift)', |
81 | bcopts => '-basic', |
82 | code => sub { my $a = shift; |
83 | if ($a) { print "foo" } |
84 | else { print "bar" } |
85 | }, |
86 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
87 | # d <1> leavesub[1 ref] K/REFC,1 ->(end) |
88 | # - <@> lineseq KP ->d |
89 | # 1 <;> nextstate(main 431 optree.t:68) v ->2 |
90 | # 6 <2> sassign vKS/2 ->7 |
91 | # 4 <1> shift sK/1 ->5 |
92 | # 3 <1> rv2av[t3] sKRM/1 ->4 |
93 | # 2 <#> gv[*_] s ->3 |
94 | # 5 <0> padsv[$a:431,435] sRM*/LVINTRO ->6 |
95 | # 7 <;> nextstate(main 435 optree.t:69) v ->8 |
96 | # - <1> null K/1 ->- |
97 | # 9 <|> cond_expr(other->a) K/1 ->e |
98 | # 8 <0> padsv[$a:431,435] s ->9 |
99 | # - <@> scope K ->- |
100 | # - <0> ex-nextstate v ->a |
101 | # c <@> print sK ->d |
102 | # a <0> pushmark s ->b |
103 | # b <$> const[PV "foo"] s ->c |
104 | # j <@> leave KP ->d |
105 | # e <0> enter ->f |
106 | # f <;> nextstate(main 433 optree.t:70) v ->g |
107 | # i <@> print sK ->j |
108 | # g <0> pushmark s ->h |
109 | # h <$> const[PV "bar"] s ->i |
110 | EOT_EOT |
724aa791 |
111 | # d <1> leavesub[1 ref] K/REFC,1 ->(end) |
112 | # - <@> lineseq KP ->d |
113 | # 1 <;> nextstate(main 428 optree_samples.t:48) v ->2 |
114 | # 6 <2> sassign vKS/2 ->7 |
115 | # 4 <1> shift sK/1 ->5 |
116 | # 3 <1> rv2av[t2] sKRM/1 ->4 |
117 | # 2 <$> gv(*_) s ->3 |
118 | # 5 <0> padsv[$a:428,432] sRM*/LVINTRO ->6 |
119 | # 7 <;> nextstate(main 432 optree_samples.t:49) v ->8 |
120 | # - <1> null K/1 ->- |
121 | # 9 <|> cond_expr(other->a) K/1 ->e |
122 | # 8 <0> padsv[$a:428,432] s ->9 |
123 | # - <@> scope K ->- |
124 | # - <0> ex-nextstate v ->a |
125 | # c <@> print sK ->d |
126 | # a <0> pushmark s ->b |
127 | # b <$> const(PV "foo") s ->c |
128 | # j <@> leave KP ->d |
129 | # e <0> enter ->f |
130 | # f <;> nextstate(main 430 optree_samples.t:50) v ->g |
131 | # i <@> print sK ->j |
132 | # g <0> pushmark s ->h |
133 | # h <$> const(PV "bar") s ->i |
134 | EONT_EONT |
135 | |
136 | checkOptree ( name => '-exec sub {if shift print then,else}', |
137 | bcopts => '-exec', |
138 | code => sub { if (shift) { print "then" } |
139 | else { print "else" } |
140 | }, |
141 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
724aa791 |
142 | # 1 <;> nextstate(main 426 optree.t:16) v |
143 | # 2 <#> gv[*_] s |
144 | # 3 <1> rv2av[t2] sKRM/1 |
145 | # 4 <1> shift sK/1 |
146 | # 5 <|> cond_expr(other->6) K/1 |
147 | # 6 <0> pushmark s |
148 | # 7 <$> const[PV "then"] s |
149 | # 8 <@> print sK |
150 | # goto 9 |
151 | # a <0> enter |
152 | # b <;> nextstate(main 424 optree.t:17) v |
153 | # c <0> pushmark s |
154 | # d <$> const[PV "else"] s |
155 | # e <@> print sK |
156 | # f <@> leave KP |
157 | # 9 <1> leavesub[1 ref] K/REFC,1 |
158 | EOT_EOT |
159 | # 1 <;> nextstate(main 436 optree_samples.t:123) v |
160 | # 2 <$> gv(*_) s |
161 | # 3 <1> rv2av[t1] sKRM/1 |
162 | # 4 <1> shift sK/1 |
163 | # 5 <|> cond_expr(other->6) K/1 |
164 | # 6 <0> pushmark s |
165 | # 7 <$> const(PV "then") s |
166 | # 8 <@> print sK |
167 | # goto 9 |
168 | # a <0> enter |
169 | # b <;> nextstate(main 434 optree_samples.t:124) v |
170 | # c <0> pushmark s |
171 | # d <$> const(PV "else") s |
172 | # e <@> print sK |
173 | # f <@> leave KP |
174 | # 9 <1> leavesub[1 ref] K/REFC,1 |
175 | EONT_EONT |
176 | |
177 | checkOptree ( name => '-exec (see above, with my $a = shift)', |
178 | bcopts => '-exec', |
179 | code => sub { my $a = shift; |
180 | if ($a) { print "foo" } |
181 | else { print "bar" } |
182 | }, |
183 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
184 | # 1 <;> nextstate(main 423 optree.t:16) v |
185 | # 2 <#> gv[*_] s |
186 | # 3 <1> rv2av[t3] sKRM/1 |
187 | # 4 <1> shift sK/1 |
188 | # 5 <0> padsv[$a:423,427] sRM*/LVINTRO |
189 | # 6 <2> sassign vKS/2 |
190 | # 7 <;> nextstate(main 427 optree.t:17) v |
191 | # 8 <0> padsv[$a:423,427] s |
192 | # 9 <|> cond_expr(other->a) K/1 |
193 | # a <0> pushmark s |
194 | # b <$> const[PV "foo"] s |
195 | # c <@> print sK |
196 | # goto d |
197 | # e <0> enter |
198 | # f <;> nextstate(main 425 optree.t:18) v |
199 | # g <0> pushmark s |
200 | # h <$> const[PV "bar"] s |
201 | # i <@> print sK |
202 | # j <@> leave KP |
203 | # d <1> leavesub[1 ref] K/REFC,1 |
204 | EOT_EOT |
205 | # 1 <;> nextstate(main 437 optree_samples.t:112) v |
206 | # 2 <$> gv(*_) s |
207 | # 3 <1> rv2av[t2] sKRM/1 |
208 | # 4 <1> shift sK/1 |
209 | # 5 <0> padsv[$a:437,441] sRM*/LVINTRO |
210 | # 6 <2> sassign vKS/2 |
211 | # 7 <;> nextstate(main 441 optree_samples.t:113) v |
212 | # 8 <0> padsv[$a:437,441] s |
213 | # 9 <|> cond_expr(other->a) K/1 |
214 | # a <0> pushmark s |
215 | # b <$> const(PV "foo") s |
216 | # c <@> print sK |
217 | # goto d |
218 | # e <0> enter |
219 | # f <;> nextstate(main 439 optree_samples.t:114) v |
220 | # g <0> pushmark s |
221 | # h <$> const(PV "bar") s |
222 | # i <@> print sK |
223 | # j <@> leave KP |
224 | # d <1> leavesub[1 ref] K/REFC,1 |
225 | EONT_EONT |
226 | |
227 | checkOptree ( name => '-exec sub { print (shift) ? "foo" : "bar" }', |
228 | code => sub { print (shift) ? "foo" : "bar" }, |
229 | bcopts => '-exec', |
230 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
231 | # 1 <;> nextstate(main 428 optree.t:31) v |
232 | # 2 <0> pushmark s |
233 | # 3 <#> gv[*_] s |
234 | # 4 <1> rv2av[t2] sKRM/1 |
235 | # 5 <1> shift sK/1 |
236 | # 6 <@> print sK |
237 | # 7 <|> cond_expr(other->8) K/1 |
238 | # 8 <$> const[PV "foo"] s |
239 | # goto 9 |
240 | # a <$> const[PV "bar"] s |
241 | # 9 <1> leavesub[1 ref] K/REFC,1 |
242 | EOT_EOT |
243 | # 1 <;> nextstate(main 442 optree_samples.t:144) v |
244 | # 2 <0> pushmark s |
245 | # 3 <$> gv(*_) s |
246 | # 4 <1> rv2av[t1] sKRM/1 |
247 | # 5 <1> shift sK/1 |
248 | # 6 <@> print sK |
249 | # 7 <|> cond_expr(other->8) K/1 |
250 | # 8 <$> const(PV "foo") s |
251 | # goto 9 |
252 | # a <$> const(PV "bar") s |
253 | # 9 <1> leavesub[1 ref] K/REFC,1 |
254 | EONT_EONT |
255 | |
256 | pass ("FOREACH"); |
257 | |
258 | checkOptree ( name => '-exec sub { foreach (1..10) {print "foo $_"} }', |
259 | code => sub { foreach (1..10) {print "foo $_"} }, |
260 | bcopts => '-exec', |
261 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
262 | # 1 <;> nextstate(main 443 optree.t:158) v |
263 | # 2 <0> pushmark s |
264 | # 3 <$> const[IV 1] s |
265 | # 4 <$> const[IV 10] s |
266 | # 5 <#> gv[*_] s |
267 | # 6 <{> enteriter(next->d last->g redo->7) lKS |
268 | # e <0> iter s |
269 | # f <|> and(other->7) K/1 |
270 | # 7 <;> nextstate(main 442 optree.t:158) v |
271 | # 8 <0> pushmark s |
272 | # 9 <$> const[PV "foo "] s |
273 | # a <#> gvsv[*_] s |
274 | # b <2> concat[t4] sK/2 |
275 | # c <@> print vK |
276 | # d <0> unstack s |
277 | # goto e |
278 | # g <2> leaveloop K/2 |
279 | # h <1> leavesub[1 ref] K/REFC,1 |
724aa791 |
280 | EOT_EOT |
281 | # 1 <;> nextstate(main 444 optree_samples.t:182) v |
282 | # 2 <0> pushmark s |
283 | # 3 <$> const(IV 1) s |
284 | # 4 <$> const(IV 10) s |
285 | # 5 <$> gv(*_) s |
286 | # 6 <{> enteriter(next->d last->g redo->7) lKS |
287 | # e <0> iter s |
288 | # f <|> and(other->7) K/1 |
289 | # 7 <;> nextstate(main 443 optree_samples.t:182) v |
290 | # 8 <0> pushmark s |
291 | # 9 <$> const(PV "foo ") s |
292 | # a <$> gvsv(*_) s |
293 | # b <2> concat[t3] sK/2 |
294 | # c <@> print vK |
295 | # d <0> unstack s |
296 | # goto e |
297 | # g <2> leaveloop K/2 |
298 | # h <1> leavesub[1 ref] K/REFC,1 |
299 | EONT_EONT |
300 | |
301 | checkOptree ( name => '-basic sub { print "foo $_" foreach (1..10) }', |
302 | code => sub { print "foo $_" foreach (1..10) }, |
303 | bcopts => '-basic', |
304 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
305 | # h <1> leavesub[1 ref] K/REFC,1 ->(end) |
306 | # - <@> lineseq KP ->h |
307 | # 1 <;> nextstate(main 445 optree.t:167) v ->2 |
308 | # 2 <;> nextstate(main 445 optree.t:167) v ->3 |
309 | # g <2> leaveloop K/2 ->h |
310 | # 7 <{> enteriter(next->d last->g redo->8) lKS ->e |
311 | # - <0> ex-pushmark s ->3 |
312 | # - <1> ex-list lK ->6 |
313 | # 3 <0> pushmark s ->4 |
314 | # 4 <$> const[IV 1] s ->5 |
315 | # 5 <$> const[IV 10] s ->6 |
316 | # 6 <#> gv[*_] s ->7 |
317 | # - <1> null K/1 ->g |
318 | # f <|> and(other->8) K/1 ->g |
319 | # e <0> iter s ->f |
320 | # - <@> lineseq sK ->- |
321 | # c <@> print vK ->d |
322 | # 8 <0> pushmark s ->9 |
323 | # - <1> ex-stringify sK/1 ->c |
324 | # - <0> ex-pushmark s ->9 |
325 | # b <2> concat[t2] sK/2 ->c |
326 | # 9 <$> const[PV "foo "] s ->a |
327 | # - <1> ex-rv2sv sK/1 ->b |
328 | # a <#> gvsv[*_] s ->b |
329 | # d <0> unstack s ->e |
330 | EOT_EOT |
331 | # h <1> leavesub[1 ref] K/REFC,1 ->(end) |
332 | # - <@> lineseq KP ->h |
333 | # 1 <;> nextstate(main 446 optree_samples.t:192) v ->2 |
334 | # 2 <;> nextstate(main 446 optree_samples.t:192) v ->3 |
335 | # g <2> leaveloop K/2 ->h |
336 | # 7 <{> enteriter(next->d last->g redo->8) lKS ->e |
337 | # - <0> ex-pushmark s ->3 |
338 | # - <1> ex-list lK ->6 |
339 | # 3 <0> pushmark s ->4 |
340 | # 4 <$> const(IV 1) s ->5 |
341 | # 5 <$> const(IV 10) s ->6 |
342 | # 6 <$> gv(*_) s ->7 |
343 | # - <1> null K/1 ->g |
344 | # f <|> and(other->8) K/1 ->g |
345 | # e <0> iter s ->f |
346 | # - <@> lineseq sK ->- |
347 | # c <@> print vK ->d |
348 | # 8 <0> pushmark s ->9 |
349 | # - <1> ex-stringify sK/1 ->c |
350 | # - <0> ex-pushmark s ->9 |
351 | # b <2> concat[t1] sK/2 ->c |
352 | # 9 <$> const(PV "foo ") s ->a |
353 | # - <1> ex-rv2sv sK/1 ->b |
354 | # a <$> gvsv(*_) s ->b |
355 | # d <0> unstack s ->e |
356 | EONT_EONT |
357 | |
498d59dd |
358 | checkOptree ( name => '-exec -e foreach (1..10) {print qq{foo $_}}', |
359 | prog => 'foreach (1..10) {print qq{foo $_}}', |
724aa791 |
360 | bcopts => '-exec', |
361 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
362 | # 1 <0> enter |
363 | # 2 <;> nextstate(main 2 -e:1) v |
364 | # 3 <0> pushmark s |
365 | # 4 <$> const[IV 1] s |
366 | # 5 <$> const[IV 10] s |
367 | # 6 <#> gv[*_] s |
368 | # 7 <{> enteriter(next->e last->h redo->8) lKS |
369 | # f <0> iter s |
370 | # g <|> and(other->8) vK/1 |
371 | # 8 <;> nextstate(main 1 -e:1) v |
372 | # 9 <0> pushmark s |
373 | # a <$> const[PV "foo "] s |
374 | # b <#> gvsv[*_] s |
375 | # c <2> concat[t4] sK/2 |
376 | # d <@> print vK |
377 | # e <0> unstack v |
378 | # goto f |
379 | # h <2> leaveloop vK/2 |
380 | # i <@> leave[1 ref] vKP/REFC |
381 | EOT_EOT |
382 | # 1 <0> enter |
383 | # 2 <;> nextstate(main 2 -e:1) v |
384 | # 3 <0> pushmark s |
385 | # 4 <$> const(IV 1) s |
386 | # 5 <$> const(IV 10) s |
387 | # 6 <$> gv(*_) s |
388 | # 7 <{> enteriter(next->e last->h redo->8) lKS |
389 | # f <0> iter s |
390 | # g <|> and(other->8) vK/1 |
391 | # 8 <;> nextstate(main 1 -e:1) v |
392 | # 9 <0> pushmark s |
393 | # a <$> const(PV "foo ") s |
394 | # b <$> gvsv(*_) s |
395 | # c <2> concat[t3] sK/2 |
396 | # d <@> print vK |
397 | # e <0> unstack v |
398 | # goto f |
399 | # h <2> leaveloop vK/2 |
400 | # i <@> leave[1 ref] vKP/REFC |
724aa791 |
401 | EONT_EONT |
402 | |
403 | checkOptree ( name => '-exec sub { print "foo $_" foreach (1..10) }', |
404 | code => sub { print "foo $_" foreach (1..10) }, |
405 | bcopts => '-exec', |
406 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
724aa791 |
407 | # 1 <;> nextstate(main 445 optree.t:167) v |
408 | # 2 <;> nextstate(main 445 optree.t:167) v |
409 | # 3 <0> pushmark s |
410 | # 4 <$> const[IV 1] s |
411 | # 5 <$> const[IV 10] s |
412 | # 6 <#> gv[*_] s |
413 | # 7 <{> enteriter(next->d last->g redo->8) lKS |
414 | # e <0> iter s |
415 | # f <|> and(other->8) K/1 |
416 | # 8 <0> pushmark s |
417 | # 9 <$> const[PV "foo "] s |
418 | # a <#> gvsv[*_] s |
419 | # b <2> concat[t2] sK/2 |
420 | # c <@> print vK |
421 | # d <0> unstack s |
422 | # goto e |
423 | # g <2> leaveloop K/2 |
424 | # h <1> leavesub[1 ref] K/REFC,1 |
425 | EOT_EOT |
426 | # 1 <;> nextstate(main 447 optree_samples.t:252) v |
427 | # 2 <;> nextstate(main 447 optree_samples.t:252) v |
428 | # 3 <0> pushmark s |
429 | # 4 <$> const(IV 1) s |
430 | # 5 <$> const(IV 10) s |
431 | # 6 <$> gv(*_) s |
432 | # 7 <{> enteriter(next->d last->g redo->8) lKS |
433 | # e <0> iter s |
434 | # f <|> and(other->8) K/1 |
435 | # 8 <0> pushmark s |
436 | # 9 <$> const(PV "foo ") s |
437 | # a <$> gvsv(*_) s |
438 | # b <2> concat[t1] sK/2 |
439 | # c <@> print vK |
440 | # d <0> unstack s |
441 | # goto e |
442 | # g <2> leaveloop K/2 |
443 | # h <1> leavesub[1 ref] K/REFC,1 |
444 | EONT_EONT |
445 | |
cc02ea56 |
446 | pass("GREP: SAMPLES FROM PERLDOC -F GREP"); |
447 | |
448 | checkOptree ( name => '@foo = grep(!/^\#/, @bar)', |
449 | code => '@foo = grep(!/^\#/, @bar)', |
450 | bcopts => '-exec', |
451 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
452 | # 1 <;> nextstate(main 496 (eval 20):1) v |
453 | # 2 <0> pushmark s |
454 | # 3 <0> pushmark s |
455 | # 4 <#> gv[*bar] s |
456 | # 5 <1> rv2av[t4] lKM/1 |
457 | # 6 <@> grepstart lK |
458 | # 7 <|> grepwhile(other->8)[t5] lK |
459 | # 8 </> match(/"^#"/) s/RTIME |
460 | # 9 <1> not sK/1 |
461 | # goto 7 |
462 | # a <0> pushmark s |
463 | # b <#> gv[*foo] s |
464 | # c <1> rv2av[t2] lKRM*/1 |
465 | # d <2> aassign[t6] KS/COMMON |
466 | # e <1> leavesub[1 ref] K/REFC,1 |
467 | EOT_EOT |
468 | # 1 <;> nextstate(main 496 (eval 20):1) v |
469 | # 2 <0> pushmark s |
470 | # 3 <0> pushmark s |
471 | # 4 <$> gv(*bar) s |
472 | # 5 <1> rv2av[t2] lKM/1 |
473 | # 6 <@> grepstart lK |
474 | # 7 <|> grepwhile(other->8)[t3] lK |
475 | # 8 </> match(/"^\\#"/) s/RTIME |
476 | # 9 <1> not sK/1 |
477 | # goto 7 |
478 | # a <0> pushmark s |
479 | # b <$> gv(*foo) s |
480 | # c <1> rv2av[t1] lKRM*/1 |
481 | # d <2> aassign[t4] KS/COMMON |
482 | # e <1> leavesub[1 ref] K/REFC,1 |
483 | EONT_EONT |
484 | |
485 | |
486 | pass("MAP: SAMPLES FROM PERLDOC -F MAP"); |
487 | |
488 | checkOptree ( name => '%h = map { getkey($_) => $_ } @a', |
489 | code => '%h = map { getkey($_) => $_ } @a', |
490 | bcopts => '-exec', |
491 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
492 | # 1 <;> nextstate(main 501 (eval 22):1) v |
493 | # 2 <0> pushmark s |
494 | # 3 <0> pushmark s |
495 | # 4 <#> gv[*a] s |
496 | # 5 <1> rv2av[t8] lKM/1 |
497 | # 6 <@> mapstart lK* |
498 | # 7 <|> mapwhile(other->8)[t9] lK |
499 | # 8 <0> enter l |
500 | # 9 <;> nextstate(main 500 (eval 22):1) v |
501 | # a <0> pushmark s |
502 | # b <0> pushmark s |
503 | # c <#> gvsv[*_] s |
504 | # d <#> gv[*getkey] s/EARLYCV |
505 | # e <1> entersub[t5] lKS/TARG,1 |
506 | # f <#> gvsv[*_] s |
507 | # g <@> list lK |
508 | # h <@> leave lKP |
509 | # goto 7 |
510 | # i <0> pushmark s |
511 | # j <#> gv[*h] s |
512 | # k <1> rv2hv[t2] lKRM*/1 |
513 | # l <2> aassign[t10] KS/COMMON |
514 | # m <1> leavesub[1 ref] K/REFC,1 |
515 | EOT_EOT |
516 | # 1 <;> nextstate(main 501 (eval 22):1) v |
517 | # 2 <0> pushmark s |
518 | # 3 <0> pushmark s |
519 | # 4 <$> gv(*a) s |
520 | # 5 <1> rv2av[t3] lKM/1 |
521 | # 6 <@> mapstart lK* |
522 | # 7 <|> mapwhile(other->8)[t4] lK |
523 | # 8 <0> enter l |
524 | # 9 <;> nextstate(main 500 (eval 22):1) v |
525 | # a <0> pushmark s |
526 | # b <0> pushmark s |
527 | # c <$> gvsv(*_) s |
528 | # d <$> gv(*getkey) s/EARLYCV |
529 | # e <1> entersub[t2] lKS/TARG,1 |
530 | # f <$> gvsv(*_) s |
531 | # g <@> list lK |
532 | # h <@> leave lKP |
533 | # goto 7 |
534 | # i <0> pushmark s |
535 | # j <$> gv(*h) s |
536 | # k <1> rv2hv[t1] lKRM*/1 |
537 | # l <2> aassign[t5] KS/COMMON |
538 | # m <1> leavesub[1 ref] K/REFC,1 |
539 | EONT_EONT |
540 | |
541 | checkOptree ( name => '%h=(); for $_(@a){$h{getkey($_)} = $_}', |
542 | code => '%h=(); for $_(@a){$h{getkey($_)} = $_}', |
543 | bcopts => '-exec', |
544 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
545 | # 1 <;> nextstate(main 505 (eval 24):1) v |
546 | # 2 <0> pushmark s |
547 | # 3 <0> pushmark s |
548 | # 4 <#> gv[*h] s |
549 | # 5 <1> rv2hv[t2] lKRM*/1 |
550 | # 6 <2> aassign[t3] vKS |
551 | # 7 <;> nextstate(main 506 (eval 24):1) v |
552 | # 8 <0> pushmark sM |
553 | # 9 <#> gv[*a] s |
554 | # a <1> rv2av[t6] sKRM/1 |
555 | # b <#> gv[*_] s |
556 | # c <1> rv2gv sKRM/1 |
557 | # d <{> enteriter(next->o last->r redo->e) lKS |
558 | # p <0> iter s |
559 | # q <|> and(other->e) K/1 |
560 | # e <;> nextstate(main 505 (eval 24):1) v |
561 | # f <#> gvsv[*_] s |
562 | # g <#> gv[*h] s |
563 | # h <1> rv2hv sKR/1 |
564 | # i <0> pushmark s |
565 | # j <#> gvsv[*_] s |
566 | # k <#> gv[*getkey] s/EARLYCV |
567 | # l <1> entersub[t10] sKS/TARG,1 |
568 | # m <2> helem sKRM*/2 |
569 | # n <2> sassign vKS/2 |
570 | # o <0> unstack s |
571 | # goto p |
572 | # r <2> leaveloop K/2 |
573 | # s <1> leavesub[1 ref] K/REFC,1 |
574 | EOT_EOT |
575 | # 1 <;> nextstate(main 505 (eval 24):1) v |
576 | # 2 <0> pushmark s |
577 | # 3 <0> pushmark s |
578 | # 4 <$> gv(*h) s |
579 | # 5 <1> rv2hv[t1] lKRM*/1 |
580 | # 6 <2> aassign[t2] vKS |
581 | # 7 <;> nextstate(main 506 (eval 24):1) v |
582 | # 8 <0> pushmark sM |
583 | # 9 <$> gv(*a) s |
584 | # a <1> rv2av[t3] sKRM/1 |
585 | # b <$> gv(*_) s |
586 | # c <1> rv2gv sKRM/1 |
587 | # d <{> enteriter(next->o last->r redo->e) lKS |
588 | # p <0> iter s |
589 | # q <|> and(other->e) K/1 |
590 | # e <;> nextstate(main 505 (eval 24):1) v |
591 | # f <$> gvsv(*_) s |
592 | # g <$> gv(*h) s |
593 | # h <1> rv2hv sKR/1 |
594 | # i <0> pushmark s |
595 | # j <$> gvsv(*_) s |
596 | # k <$> gv(*getkey) s/EARLYCV |
597 | # l <1> entersub[t4] sKS/TARG,1 |
598 | # m <2> helem sKRM*/2 |
599 | # n <2> sassign vKS/2 |
600 | # o <0> unstack s |
601 | # goto p |
602 | # r <2> leaveloop K/2 |
603 | # s <1> leavesub[1 ref] K/REFC,1 |
604 | EONT_EONT |
605 | |
606 | checkOptree ( name => 'map $_+42, 10..20', |
607 | code => 'map $_+42, 10..20', |
608 | bcopts => '-exec', |
609 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
610 | # 1 <;> nextstate(main 497 (eval 20):1) v |
611 | # 2 <0> pushmark s |
612 | # 3 <$> const[AV ] s |
613 | # 4 <1> rv2av lKPM/1 |
614 | # 5 <@> mapstart K |
615 | # 6 <|> mapwhile(other->7)[t7] K |
616 | # 7 <#> gvsv[*_] s |
617 | # 8 <$> const[IV 42] s |
618 | # 9 <2> add[t2] sK/2 |
619 | # goto 6 |
620 | # a <1> leavesub[1 ref] K/REFC,1 |
621 | EOT_EOT |
622 | # 1 <;> nextstate(main 511 (eval 26):1) v |
623 | # 2 <0> pushmark s |
624 | # 3 <$> const(AV ) s |
625 | # 4 <1> rv2av lKPM/1 |
626 | # 5 <@> mapstart K |
627 | # 6 <|> mapwhile(other->7)[t4] K |
628 | # 7 <$> gvsv(*_) s |
629 | # 8 <$> const(IV 42) s |
630 | # 9 <2> add[t1] sK/2 |
631 | # goto 6 |
632 | # a <1> leavesub[1 ref] K/REFC,1 |
633 | EONT_EONT |
634 | |
635 | pass("CONSTANTS"); |
636 | |
498d59dd |
637 | checkOptree ( name => '-e use constant j => qq{junk}; print j', |
638 | prog => 'use constant j => qq{junk}; print j', |
724aa791 |
639 | bcopts => '-exec', |
640 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
641 | # 1 <0> enter |
642 | # 2 <;> nextstate(main 71 -e:1) v |
643 | # 3 <0> pushmark s |
644 | # 4 <$> const[PV "junk"] s |
645 | # 5 <@> print vK |
646 | # 6 <@> leave[1 ref] vKP/REFC |
647 | EOT_EOT |
648 | # 1 <0> enter |
649 | # 2 <;> nextstate(main 71 -e:1) v |
650 | # 3 <0> pushmark s |
651 | # 4 <$> const(PV "junk") s |
652 | # 5 <@> print vK |
653 | # 6 <@> leave[1 ref] vKP/REFC |
654 | EONT_EONT |
655 | |
2ce64696 |
656 | } # skip |
657 | |
724aa791 |
658 | __END__ |
659 | |
660 | ####################################################################### |
661 | |
662 | checkOptree ( name => '-exec sub a { print (shift) ? "foo" : "bar" }', |
663 | code => sub { print (shift) ? "foo" : "bar" }, |
664 | bcopts => '-exec', |
665 | expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT'); |
666 | insert threaded reference here |
667 | EOT_EOT |
668 | insert non-threaded reference here |
669 | EONT_EONT |
670 | |