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