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