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