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 ];
55 my ($height, $level, $i) = @_;
56 push @_, $i = 0 if @_ == 2;
58 my $up = $i == $height + 1 ? $call->(@_) : gen($height, $level, $i + 1);
59 my $active = $i <= ($height - $level);
61 my ($code, $exp) = @$base;
62 for my $blk (@blocks) {
63 for my $cx (@contexts) {
65 $blk->[0] . $cx->[0] . $code . $cx->[1] . $blk->[1],
66 contextify($cx->[2], $active, $exp),
68 my @items = map { int rand 10 } 0 .. rand 3;
69 my $list = join ', ', @items;
71 $blk->[0] . $cx->[0] . "($list, $code)" . $cx->[1] . $blk->[1],
72 contextify($cx->[2], $active, $exp, @items),
80 sub linearize { join ', ', map { defined($_) ? $_ : '(undef)' } @_ }
85 for my $s (reverse @spec) {
88 } elsif ($s =~ /^[0-9]+$/) {
91 @acc = (@acc ? $acc[-1] : undef);
96 return linearize @acc;
100 my ($height, $level) = @_;
106 my $res = linearize eval $_->[0];
109 $res = '*TEST DID NOT COMPILE*';
111 $exp = expect $_->[1];
115 === This testcase failed ===
117 ==== vvvvv Errors vvvvvv ===
120 is $res, $exp, "stress unwind $height $level $i";
124 for ([ ], [ 'A' ], [ qw<B C> ]) {