7 use Test::Leaner 'no_plan';
9 use Scope::Upper qw<unwind UP HERE>;
14 my ($height, $level, $i) = @_;
15 $level = $level ? 'UP ' x $level : 'HERE';
16 return [ [ "unwind(\@args => $level)\n", [ \@args ] ] ];
19 # @_[0 .. $#_] also ought to work, but it sometimes evaluates to nonsense in
20 # scalar context on perl 5.8.5 and below.
22 sub list { wantarray ? @_ : $_[$#_] }
31 [ 'scalar(', ')', 's' ],
32 [ 'list(', ')', 'l' ],
35 for my $block (@blocks) {
36 $_ .= "\n" for @$block[0, 1];
38 for my $cxt (@contexts) {
39 $_ .= "\n" for @$cxt[0, 1];
43 my ($cxt, $active, $exp, @items) = @_;
44 return $exp unless $active;
47 } elsif ($cxt eq 's') {
48 return [ $cxt, @$exp ];
50 return [ @items, @$exp ];
58 my ($height, $level, $i) = @_;
59 push @_, $i = 0 if @_ == 2;
61 my $up = $i == $height + 1 ? $call->(@_) : gen($height, $level, $i + 1);
62 my $active = $i <= ($height - $level);
64 my ($code, $exp) = @$base;
65 for my $blk (@blocks) {
66 for my $cx (@contexts) {
68 $blk->[0] . $cx->[0] . $code . $cx->[1] . $blk->[1],
69 contextify($cx->[2], $active, $exp),
71 my @items = map $integer++, 0 .. ($items++ % 3);
72 my $list = join ', ', @items;
74 $blk->[0] . $cx->[0] . "($list, $code)" . $cx->[1] . $blk->[1],
75 contextify($cx->[2], $active, $exp, @items),
83 sub linearize { join ', ', map { defined($_) ? $_ : '(undef)' } @_ }
88 for my $s (reverse @spec) {
91 } elsif ($s =~ /^[0-9]+$/) {
94 @acc = (@acc ? $acc[-1] : undef);
99 return linearize @acc;
103 my ($height, $level) = @_;
109 my $res = linearize eval $_->[0];
112 $res = '*TEST DID NOT COMPILE*';
114 $exp = expect $_->[1];
118 === This testcase failed ===
120 ==== vvvvv Errors vvvvvv ===
123 is $res, $exp, "stress unwind $height $level $i";
127 for ([ ], [ 'A' ], [ qw<B C> ]) {