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