6 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
7 print "1..0 # Skip -- Perl configured without B module\n";
10 if (!$Config::Config{useperlio}) {
11 print "1..0 # Skip -- need perlio to walk the optree\n";
20 Code test snippets here are adapted from `perldoc -f map`
22 Due to a bleadperl optimization (Dave Mitchell, circa apr 04), the
23 (map|grep)(start|while) opcodes have different flags in 5.9, their
24 private flags /1, /2 are gone in blead (for the cases covered)
26 When the optree stuff was integrated into 5.8.6, these tests failed,
27 and were todo'd. They're now done, by version-specific tweaking in
28 mkCheckRex(), therefore the skip is removed too.
33 #examples poached from perldoc -f sort
35 NOTE: name is no longer a required arg for checkOptree, as label is
36 synthesized out of others. HOWEVER, if the test-code has newlines in
37 it, the label must be overridden by an explicit name.
39 This is because t/TEST is quite particular about the test output it
40 processes, and multi-line labels violate its 1-line-per-test
45 # chunk: # sort lexically
46 @articles = sort @files;
50 checkOptree(note => q{},
52 code => q{@articles = sort @files; },
53 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
54 # 1 <;> nextstate(main 545 (eval 15):1) v
58 # 5 <1> rv2av[t4] lK/1
61 # 8 <#> gv[*articles] s
62 # 9 <1> rv2av[t2] lKRM*/1
63 # a <2> aassign[t5] KS/COMMON
64 # b <1> leavesub[1 ref] K/REFC,1
66 # 1 <;> nextstate(main 545 (eval 15):1) v
70 # 5 <1> rv2av[t2] lK/1
73 # 8 <$> gv(*articles) s
74 # 9 <1> rv2av[t1] lKRM*/1
75 # a <2> aassign[t3] KS/COMMON
76 # b <1> leavesub[1 ref] K/REFC,1
82 # chunk: # same thing, but with explicit sort routine
83 @articles = sort {$a cmp $b} @files;
87 checkOptree(note => q{},
89 code => q{@articles = sort {$a cmp $b} @files; },
90 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
91 # 1 <;> nextstate(main 546 (eval 15):1) v
95 # 5 <1> rv2av[t7] lK/1
98 # 8 <#> gv[*articles] s
99 # 9 <1> rv2av[t2] lKRM*/1
100 # a <2> aassign[t3] KS/COMMON
101 # b <1> leavesub[1 ref] K/REFC,1
103 # 1 <;> nextstate(main 546 (eval 15):1) v
107 # 5 <1> rv2av[t3] lK/1
110 # 8 <$> gv(*articles) s
111 # 9 <1> rv2av[t1] lKRM*/1
112 # a <2> aassign[t2] KS/COMMON
113 # b <1> leavesub[1 ref] K/REFC,1
119 # chunk: # now case-insensitively
120 @articles = sort {uc($a) cmp uc($b)} @files;
124 checkOptree(note => q{},
126 code => q{@articles = sort {uc($a) cmp uc($b)} @files; },
127 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
128 # 1 <;> nextstate(main 546 (eval 15):1) v
132 # 5 <1> rv2av[t9] lK/1 < 5.019002
133 # 5 <1> rv2av[t9] lKM/1 >=5.019002
136 # 8 <#> gv[*articles] s
137 # 9 <1> rv2av[t2] lKRM*/1
138 # a <2> aassign[t10] KS/COMMON
139 # b <1> leavesub[1 ref] K/REFC,1
141 # 1 <;> nextstate(main 546 (eval 15):1) v
145 # 5 <1> rv2av[t5] lK/1 < 5.019002
146 # 5 <1> rv2av[t5] lKM/1 >=5.019002
149 # 8 <$> gv(*articles) s
150 # 9 <1> rv2av[t1] lKRM*/1
151 # a <2> aassign[t6] KS/COMMON
152 # b <1> leavesub[1 ref] K/REFC,1
158 # chunk: # same thing in reversed order
159 @articles = sort {$b cmp $a} @files;
163 checkOptree(note => q{},
165 code => q{@articles = sort {$b cmp $a} @files; },
166 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
167 # 1 <;> nextstate(main 546 (eval 15):1) v
171 # 5 <1> rv2av[t7] lK/1
174 # 8 <#> gv[*articles] s
175 # 9 <1> rv2av[t2] lKRM*/1
176 # a <2> aassign[t3] KS/COMMON
177 # b <1> leavesub[1 ref] K/REFC,1
179 # 1 <;> nextstate(main 546 (eval 15):1) v
183 # 5 <1> rv2av[t3] lK/1
186 # 8 <$> gv(*articles) s
187 # 9 <1> rv2av[t1] lKRM*/1
188 # a <2> aassign[t2] KS/COMMON
189 # b <1> leavesub[1 ref] K/REFC,1
195 # chunk: # sort numerically ascending
196 @articles = sort {$a <=> $b} @files;
200 checkOptree(note => q{},
202 code => q{@articles = sort {$a <=> $b} @files; },
203 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
204 # 1 <;> nextstate(main 546 (eval 15):1) v
208 # 5 <1> rv2av[t7] lK/1
211 # 8 <#> gv[*articles] s
212 # 9 <1> rv2av[t2] lKRM*/1
213 # a <2> aassign[t3] KS/COMMON
214 # b <1> leavesub[1 ref] K/REFC,1
216 # 1 <;> nextstate(main 546 (eval 15):1) v
220 # 5 <1> rv2av[t3] lK/1
223 # 8 <$> gv(*articles) s
224 # 9 <1> rv2av[t1] lKRM*/1
225 # a <2> aassign[t2] KS/COMMON
226 # b <1> leavesub[1 ref] K/REFC,1
232 # chunk: # sort numerically descending
233 @articles = sort {$b <=> $a} @files;
237 checkOptree(note => q{},
239 code => q{@articles = sort {$b <=> $a} @files; },
240 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
241 # 1 <;> nextstate(main 587 (eval 26):1) v
245 # 5 <1> rv2av[t7] lK/1
246 # 6 <@> sort lK/DESC,NUM
248 # 8 <#> gv[*articles] s
249 # 9 <1> rv2av[t2] lKRM*/1
250 # a <2> aassign[t3] KS/COMMON
251 # b <1> leavesub[1 ref] K/REFC,1
253 # 1 <;> nextstate(main 546 (eval 15):1) v
257 # 5 <1> rv2av[t3] lK/1
258 # 6 <@> sort lK/DESC,NUM
260 # 8 <$> gv(*articles) s
261 # 9 <1> rv2av[t1] lKRM*/1
262 # a <2> aassign[t2] KS/COMMON
263 # b <1> leavesub[1 ref] K/REFC,1
269 # chunk: # this sorts the %age hash by value instead of key
270 # using an in-line function
271 @eldest = sort { $age{$b} <=> $age{$a} } keys %age;
275 checkOptree(note => q{},
277 code => q{@eldest = sort { $age{$b} <=> $age{$a} } keys %age; },
278 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
279 # 1 <;> nextstate(main 592 (eval 28):1) v
283 # 5 <1> rv2hv[t9] lKRM/1 < 5.019006
284 # 5 <1> rv2hv lKRM/1 >=5.019006
285 # 6 <1> keys[t10] lK/1 < 5.019002
286 # 6 <1> keys[t10] lKM/1 >=5.019002
289 # 9 <#> gv[*eldest] s
290 # a <1> rv2av[t2] lKRM*/1
291 # b <2> aassign[t11] KS/COMMON
292 # c <1> leavesub[1 ref] K/REFC,1
294 # 1 <;> nextstate(main 546 (eval 15):1) v
298 # 5 <1> rv2hv[t3] lKRM/1 < 5.019006
299 # 5 <1> rv2hv lKRM/1 >=5.019006
300 # 6 <1> keys[t4] lK/1 < 5.019002
301 # 6 <1> keys[t4] lKM/1 >=5.019002
304 # 9 <$> gv(*eldest) s
305 # a <1> rv2av[t1] lKRM*/1
306 # b <2> aassign[t5] KS/COMMON
307 # c <1> leavesub[1 ref] K/REFC,1
313 # chunk: # sort using explicit subroutine name
315 $age{$a} <=> $age{$b}; # presuming numeric
317 @sortedclass = sort byage @class;
321 checkOptree(note => q{},
323 code => q{sub byage { $age{$a} <=> $age{$b}; } @sortedclass = sort byage @class; },
324 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
325 # 1 <;> nextstate(main 597 (eval 30):1) v
328 # 4 <$> const[PV "byage"] s/BARE
330 # 6 <1> rv2av[t4] lK/1 < 5.019002
331 # 6 <1> rv2av[t4] lKM/1 >=5.019002
334 # 9 <#> gv[*sortedclass] s
335 # a <1> rv2av[t2] lKRM*/1
336 # b <2> aassign[t5] KS/COMMON
337 # c <1> leavesub[1 ref] K/REFC,1
339 # 1 <;> nextstate(main 546 (eval 15):1) v
342 # 4 <$> const(PV "byage") s/BARE
344 # 6 <1> rv2av[t2] lK/1 < 5.019002
345 # 6 <1> rv2av[t2] lKM/1 >=5.019002
348 # 9 <$> gv(*sortedclass) s
349 # a <1> rv2av[t1] lKRM*/1
350 # b <2> aassign[t3] KS/COMMON
351 # c <1> leavesub[1 ref] K/REFC,1
357 # chunk: sub backwards { $b cmp $a }
358 @harry = qw(dog cat x Cain Abel);
359 @george = qw(gone chased yz Punished Axed);
361 # prints AbelCaincatdogx
362 print sort backwards @harry;
363 # prints xdogcatCainAbel
364 print sort @george, 'to', @harry;
365 # prints AbelAxedCainPunishedcatchaseddoggonetoxyz
369 checkOptree(name => q{sort USERSUB LIST },
371 code => q{sub backwards { $b cmp $a }
372 @harry = qw(dog cat x Cain Abel);
373 @george = qw(gone chased yz Punished Axed);
374 print sort @harry; print sort backwards @harry;
375 print sort @george, 'to', @harry; },
376 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
377 # 1 <;> nextstate(main 602 (eval 32):2) v
379 # 3 <$> const[PV "dog"] s
380 # 4 <$> const[PV "cat"] s
381 # 5 <$> const[PV "x"] s
382 # 6 <$> const[PV "Cain"] s
383 # 7 <$> const[PV "Abel"] s
386 # a <1> rv2av[t2] lKRM*/1
387 # b <2> aassign[t3] vKS
388 # c <;> nextstate(main 602 (eval 32):3) v
390 # e <$> const[PV "gone"] s
391 # f <$> const[PV "chased"] s
392 # g <$> const[PV "yz"] s
393 # h <$> const[PV "Punished"] s
394 # i <$> const[PV "Axed"] s
396 # k <#> gv[*george] s
397 # l <1> rv2av[t5] lKRM*/1
398 # m <2> aassign[t6] vKS
399 # n <;> nextstate(main 602 (eval 32):4) v:{
403 # r <1> rv2av[t8] lK/1
406 # u <;> nextstate(main 602 (eval 32):4) v:{
409 # x <$> const[PV "backwards"] s/BARE
411 # z <1> rv2av[t10] lK/1 < 5.019002
412 # z <1> rv2av[t10] lKM/1 >=5.019002
415 # 12 <;> nextstate(main 602 (eval 32):5) v:{
418 # 15 <#> gv[*george] s
419 # 16 <1> rv2av[t12] lK/1
420 # 17 <$> const[PV "to"] s
421 # 18 <#> gv[*harry] s
422 # 19 <1> rv2av[t14] lK/1
425 # 1c <1> leavesub[1 ref] K/REFC,1
427 # 1 <;> nextstate(main 602 (eval 32):2) v
429 # 3 <$> const(PV "dog") s
430 # 4 <$> const(PV "cat") s
431 # 5 <$> const(PV "x") s
432 # 6 <$> const(PV "Cain") s
433 # 7 <$> const(PV "Abel") s
436 # a <1> rv2av[t1] lKRM*/1
437 # b <2> aassign[t2] vKS
438 # c <;> nextstate(main 602 (eval 32):3) v
440 # e <$> const(PV "gone") s
441 # f <$> const(PV "chased") s
442 # g <$> const(PV "yz") s
443 # h <$> const(PV "Punished") s
444 # i <$> const(PV "Axed") s
446 # k <$> gv(*george) s
447 # l <1> rv2av[t3] lKRM*/1
448 # m <2> aassign[t4] vKS
449 # n <;> nextstate(main 602 (eval 32):4) v:{
453 # r <1> rv2av[t5] lK/1
456 # u <;> nextstate(main 602 (eval 32):4) v:{
459 # x <$> const(PV "backwards") s/BARE
461 # z <1> rv2av[t6] lK/1 < 5.019002
462 # z <1> rv2av[t6] lKM/1 >=5.019002
465 # 12 <;> nextstate(main 602 (eval 32):5) v:{
468 # 15 <$> gv(*george) s
469 # 16 <1> rv2av[t7] lK/1
470 # 17 <$> const(PV "to") s
471 # 18 <$> gv(*harry) s
472 # 19 <1> rv2av[t8] lK/1
475 # 1c <1> leavesub[1 ref] K/REFC,1
481 # chunk: # inefficiently sort by descending numeric compare using
482 # the first integer after the first = sign, or the
483 # whole record case-insensitively otherwise
485 $nums[$b] <=> $nums[$a]
486 || $caps[$a] cmp $caps[$b]
492 # chunk: # same thing, but without any temps
493 @new = map { $_->[0] }
494 sort { $b->[1] <=> $a->[1]
495 || $a->[2] cmp $b->[2]
496 } map { [$_, /=(\d+)/, uc($_)] } @old;
500 checkOptree(name => q{Compound sort/map Expression },
502 code => q{ @new = map { $_->[0] }
503 sort { $b->[1] <=> $a->[1] || $a->[2] cmp $b->[2] }
504 map { [$_, /=(\d+)/, uc($_)] } @old; },
505 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
506 # 1 <;> nextstate(main 609 (eval 34):3) v:{
512 # 7 <1> rv2av[t19] lKM/1
513 # 8 <@> mapstart lK* < 5.017002
514 # 8 <@> mapstart lK >=5.017002
515 # 9 <|> mapwhile(other->a)[t20] lK < 5.019002
516 # 9 <|> mapwhile(other->a)[t20] lKM >=5.019002
518 # b <;> nextstate(main 608 (eval 34):2) v:{
521 # e </> match(/"=(\\d+)"/) l/RTIME
524 # h <@> anonlist sK*/1
528 # k <@> mapstart lK* < 5.017002
529 # k <@> mapstart lK >=5.017002
530 # l <|> mapwhile(other->m)[t26] lK
532 # n <1> rv2sv sKM/DREFAV,1
533 # o <1> rv2av[t4] sKR/1
534 # p <$> const[IV 0] s
536 # - <@> scope lK < 5.017002
540 # t <1> rv2av[t2] lKRM*/1
541 # u <2> aassign[t27] KS/COMMON
542 # v <1> leavesub[1 ref] K/REFC,1
544 # 1 <;> nextstate(main 609 (eval 34):3) v:{
550 # 7 <1> rv2av[t10] lKM/1
551 # 8 <@> mapstart lK* < 5.017002
552 # 8 <@> mapstart lK >=5.017002
553 # 9 <|> mapwhile(other->a)[t11] lK < 5.019002
554 # 9 <|> mapwhile(other->a)[t11] lKM >=5.019002
556 # b <;> nextstate(main 608 (eval 34):2) v:{
559 # e </> match(/"=(\\d+)"/) l/RTIME
562 # h <@> anonlist sK*/1
566 # k <@> mapstart lK* < 5.017002
567 # k <@> mapstart lK >=5.017002
568 # l <|> mapwhile(other->m)[t12] lK
570 # n <1> rv2sv sKM/DREFAV,1
571 # o <1> rv2av[t2] sKR/1
572 # p <$> const(IV 0) s
574 # - <@> scope lK < 5.017002
578 # t <1> rv2av[t1] lKRM*/1
579 # u <2> aassign[t13] KS/COMMON
580 # v <1> leavesub[1 ref] K/REFC,1
586 # chunk: # using a prototype allows you to use any comparison subroutine
587 # as a sort subroutine (including other package's subroutines)
589 sub backwards ($$) { $_[1] cmp $_[0]; } # $a and $b are not set here
591 @new = sort other::backwards @old;
595 checkOptree(name => q{sort other::sub LIST },
597 code => q{package other; sub backwards ($$) { $_[1] cmp $_[0]; }
598 package main; @new = sort other::backwards @old; },
599 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
600 # 1 <;> nextstate(main 614 (eval 36):2) v:{
603 # 4 <$> const[PV "other::backwards"] s/BARE
605 # 6 <1> rv2av[t4] lK/1 < 5.019002
606 # 6 <1> rv2av[t4] lKM/1 >=5.019002
610 # a <1> rv2av[t2] lKRM*/1
611 # b <2> aassign[t5] KS/COMMON
612 # c <1> leavesub[1 ref] K/REFC,1
614 # 1 <;> nextstate(main 614 (eval 36):2) v:{
617 # 4 <$> const(PV "other::backwards") s/BARE
619 # 6 <1> rv2av[t2] lK/1 < 5.019002
620 # 6 <1> rv2av[t2] lKM/1 >=5.019002
624 # a <1> rv2av[t1] lKRM*/1
625 # b <2> aassign[t3] KS/COMMON
626 # c <1> leavesub[1 ref] K/REFC,1
632 # chunk: # repeat, condensed. $main::a and $b are unaffected
633 sub other::backwards ($$) { $_[1] cmp $_[0]; }
634 @new = sort other::backwards @old;
638 checkOptree(note => q{},
640 code => q{sub other::backwards ($$) { $_[1] cmp $_[0]; } @new = sort other::backwards @old; },
641 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
642 # 1 <;> nextstate(main 619 (eval 38):1) v
645 # 4 <$> const[PV "other::backwards"] s/BARE
647 # 6 <1> rv2av[t4] lK/1 < 5.019002
648 # 6 <1> rv2av[t4] lKM/1 >=5.019002
652 # a <1> rv2av[t2] lKRM*/1
653 # b <2> aassign[t5] KS/COMMON
654 # c <1> leavesub[1 ref] K/REFC,1
656 # 1 <;> nextstate(main 546 (eval 15):1) v
659 # 4 <$> const(PV "other::backwards") s/BARE
661 # 6 <1> rv2av[t2] lK/1 < 5.019002
662 # 6 <1> rv2av[t2] lKM/1 >=5.019002
666 # a <1> rv2av[t1] lKRM*/1
667 # b <2> aassign[t3] KS/COMMON
668 # c <1> leavesub[1 ref] K/REFC,1
674 # chunk: # guarantee stability, regardless of algorithm
676 @new = sort { substr($a, 3, 5) cmp substr($b, 3, 5) } @old;
680 my ($expect, $expect_nt) = (<<'EOT_EOT', <<'EONT_EONT');
681 # 1 <;> nextstate(main 656 (eval 40):1) v:%,{
685 # 5 <1> rv2av[t9] lK/1 < 5.019002
686 # 5 <1> rv2av[t9] lKM/1 >=5.019002
687 # 6 <@> sort lKS*/STABLE
690 # 9 <1> rv2av[t2] lKRM*/1
691 # a <2> aassign[t14] KS/COMMON
692 # b <1> leavesub[1 ref] K/REFC,1
694 # 1 <;> nextstate(main 578 (eval 15):1) v:%,{
698 # 5 <1> rv2av[t5] lK/1 < 5.019002
699 # 5 <1> rv2av[t5] lKM/1 >=5.019002
700 # 6 <@> sort lKS*/STABLE
703 # 9 <1> rv2av[t1] lKRM*/1
704 # a <2> aassign[t6] KS/COMMON
705 # b <1> leavesub[1 ref] K/REFC,1
709 checkOptree(note => q{},
711 code => q{use sort 'stable'; @new = sort { substr($a, 3, 5) cmp substr($b, 3, 5) } @old; },
712 expect => $expect, expect_nt => $expect_nt);
716 # chunk: # force use of mergesort (not portable outside Perl 5.8)
717 use sort '_mergesort';
718 @new = sort { substr($a, 3, 5) cmp substr($b, 3, 5) } @old;
722 checkOptree(note => q{},
724 code => q{use sort '_mergesort'; @new = sort { substr($a, 3, 5) cmp substr($b, 3, 5) } @old; },
725 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
726 # 1 <;> nextstate(main 662 (eval 42):1) v:%,{
730 # 5 <1> rv2av[t9] lK/1 < 5.019002
731 # 5 <1> rv2av[t9] lKM/1 >=5.019002
735 # 9 <1> rv2av[t2] lKRM*/1
736 # a <2> aassign[t14] KS/COMMON
737 # b <1> leavesub[1 ref] K/REFC,1
739 # 1 <;> nextstate(main 578 (eval 15):1) v:%,{
743 # 5 <1> rv2av[t5] lK/1 < 5.019002
744 # 5 <1> rv2av[t5] lKM/1 >=5.019002
748 # 9 <1> rv2av[t1] lKRM*/1
749 # a <2> aassign[t6] KS/COMMON
750 # b <1> leavesub[1 ref] K/REFC,1
756 # chunk: # you should have a good reason to do this!
757 @articles = sort {$FooPack::b <=> $FooPack::a} @files;
761 checkOptree(note => q{},
763 code => q{@articles = sort {$FooPack::b <=> $FooPack::a} @files; },
764 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
765 # 1 <;> nextstate(main 667 (eval 44):1) v
769 # 5 <1> rv2av[t7] lK/1 < 5.019002
770 # 5 <1> rv2av[t7] lKM/1 >=5.019002
773 # 8 <#> gv[*articles] s
774 # 9 <1> rv2av[t2] lKRM*/1
775 # a <2> aassign[t8] KS/COMMON
776 # b <1> leavesub[1 ref] K/REFC,1
778 # 1 <;> nextstate(main 546 (eval 15):1) v
782 # 5 <1> rv2av[t3] lK/1 < 5.019002
783 # 5 <1> rv2av[t3] lKM/1 >=5.019002
786 # 8 <$> gv(*articles) s
787 # 9 <1> rv2av[t1] lKRM*/1
788 # a <2> aassign[t4] KS/COMMON
789 # b <1> leavesub[1 ref] K/REFC,1
796 @result = sort { $a <=> $b } grep { $_ == $_ } @input;
800 checkOptree(note => q{},
802 code => q{@result = sort { $a <=> $b } grep { $_ == $_ } @input; },
803 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
804 # 1 <;> nextstate(main 673 (eval 46):1) v
809 # 6 <1> rv2av[t9] lKM/1
810 # 7 <@> grepstart lK* < 5.017002
811 # 7 <@> grepstart lK >=5.017002
812 # 8 <|> grepwhile(other->9)[t10] lK
816 # - <@> scope sK < 5.017002
820 # e <#> gv[*result] s
821 # f <1> rv2av[t2] lKRM*/1
822 # g <2> aassign[t3] KS/COMMON
823 # h <1> leavesub[1 ref] K/REFC,1
825 # 1 <;> nextstate(main 547 (eval 15):1) v
830 # 6 <1> rv2av[t3] lKM/1
831 # 7 <@> grepstart lK* < 5.017002
832 # 7 <@> grepstart lK >=5.017002
833 # 8 <|> grepwhile(other->9)[t4] lK
837 # - <@> scope sK < 5.017002
841 # e <$> gv(*result) s
842 # f <1> rv2av[t1] lKRM*/1
843 # g <2> aassign[t2] KS/COMMON
844 # h <1> leavesub[1 ref] K/REFC,1
850 # chunk: # void return context sort
851 sort { $a <=> $b } @input;
855 checkOptree(note => q{},
857 code => q{sort { $a <=> $b } @input; },
858 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
859 # 1 <;> nextstate(main 678 (eval 48):1) v
862 # 4 <1> rv2av[t5] lK/1
864 # 6 <1> leavesub[1 ref] K/REFC,1
866 # 1 <;> nextstate(main 546 (eval 15):1) v
869 # 4 <1> rv2av[t2] lK/1
871 # 6 <1> leavesub[1 ref] K/REFC,1
877 # chunk: # more void context, propagating ?
878 sort { $a <=> $b } grep { $_ == $_ } @input;
882 checkOptree(note => q{},
884 code => q{sort { $a <=> $b } grep { $_ == $_ } @input; },
885 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
886 # 1 <;> nextstate(main 684 (eval 50):1) v
890 # 5 <1> rv2av[t7] lKM/1
891 # 6 <@> grepstart lK* < 5.017002
892 # 6 <@> grepstart lK >=5.017002
893 # 7 <|> grepwhile(other->8)[t8] lK
897 # - <@> scope sK < 5.017002
900 # c <1> leavesub[1 ref] K/REFC,1
902 # 1 <;> nextstate(main 547 (eval 15):1) v
906 # 5 <1> rv2av[t2] lKM/1
907 # 6 <@> grepstart lK* < 5.017002
908 # 6 <@> grepstart lK >=5.017002
909 # 7 <|> grepwhile(other->8)[t3] lK
913 # - <@> scope sK < 5.017002
916 # c <1> leavesub[1 ref] K/REFC,1
922 # chunk: # scalar return context sort
923 $s = sort { $a <=> $b } @input;
927 checkOptree(note => q{},
929 code => q{$s = sort { $a <=> $b } @input; },
930 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
931 # 1 <;> nextstate(main 689 (eval 52):1) v:{
934 # 4 <1> rv2av[t6] lK/1
937 # 7 <2> sassign sKS/2
938 # 8 <1> leavesub[1 ref] K/REFC,1
940 # 1 <;> nextstate(main 546 (eval 15):1) v:{
943 # 4 <1> rv2av[t2] lK/1
946 # 7 <2> sassign sKS/2
947 # 8 <1> leavesub[1 ref] K/REFC,1
953 # chunk: $s = sort { $a <=> $b } grep { $_ == $_ } @input;
957 checkOptree(note => q{},
959 code => q{$s = sort { $a <=> $b } grep { $_ == $_ } @input; },
960 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
961 # 1 <;> nextstate(main 695 (eval 54):1) v:{
965 # 5 <1> rv2av[t8] lKM/1
966 # 6 <@> grepstart lK* < 5.017002
967 # 6 <@> grepstart lK >=5.017002
968 # 7 <|> grepwhile(other->8)[t9] lK
972 # - <@> scope sK < 5.017002
976 # d <2> sassign sKS/2
977 # e <1> leavesub[1 ref] K/REFC,1
979 # 1 <;> nextstate(main 547 (eval 15):1) v:{
983 # 5 <1> rv2av[t2] lKM/1
984 # 6 <@> grepstart lK* < 5.017002
985 # 6 <@> grepstart lK >=5.017002
986 # 7 <|> grepwhile(other->8)[t3] lK
990 # - <@> scope sK < 5.017002
994 # d <2> sassign sKS/2
995 # e <1> leavesub[1 ref] K/REFC,1