1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#!/usr/bin/perl
use v5.14;
use warnings;
use Test2::V0;
BEGIN {
$] >= 5.026000 or plan skip_all => "No parse_subsignature()";
}
use feature 'signatures';
no warnings 'experimental';
use lib "t";
use testcase "t::stages";
BEGIN { $^H{"t::stages/permit"} = 1; }
{
BEGIN { $^H{'t::stages/signature-capture'} = 1; }
my $captured;
stages withsig ( $x, $y ) { BEGIN { $captured = $t::stages::captured; undef $t::stages::captured; } }
is( $captured, "(SIG[n=2])",
'captured signature start + finish before body' );
}
{
BEGIN { $^H{'t::stages/signature-capture'} = 1; }
my $captured;
stages withemptysig () { BEGIN { $captured = $t::stages::captured; undef $t::stages::captured; } }
is( $captured, "(SIG[n=0])",
'captured signature start + finish from empty signature' );
}
{
BEGIN { $^H{'t::stages/signature-add-$first'} = 1; }
stages withfirst ( $x, $y ) { return $first; }
is( withfirst( 1 .. 3 ), 1,
'signature start can add $first param' );
}
{
BEGIN { $^H{'t::stages/signature-add-@rest'} = 1; }
stages withrest ( $x, $y ) { return [ @rest ]; }
is( withrest( 1 .. 5 ), [ 3 .. 5 ],
'signature finish can add @rest param' );
}
done_testing;
|