| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
use v5.14; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use Test2::V0; |
| 7 |
BEGIN { $] >= 5.026000 or plan skip_all => "No parse_subsignature()"; } |
| 8 |
|
| 9 |
use Test2::Require::Module 'Future::AsyncAwait' => '0.66'; |
| 10 |
use Test2::Require::Module 'Sublike::Extended' => '0.29'; |
| 11 |
|
| 12 |
use feature 'signatures'; |
| 13 |
no warnings 'experimental'; |
| 14 |
|
| 15 |
use Future::AsyncAwait; |
| 16 |
use Sublike::Extended; |
| 17 |
|
| 18 |
# async extended sub |
| 19 |
{ |
| 20 |
async extended sub f1 (:$x, :$y) { return "x=$x y=$y" } |
| 21 |
|
| 22 |
is( await f1( x => "first", y => "second" ), "x=first y=second", |
| 23 |
'async extended sub' ); |
| 24 |
} |
| 25 |
|
| 26 |
# async sub + S:E 0.29 |
| 27 |
{ |
| 28 |
use Sublike::Extended 'sub'; |
| 29 |
|
| 30 |
async sub f2 (:$x, :$y) { return "x=$x y=$y" } |
| 31 |
|
| 32 |
is( await f2( x => "third", y => "fourth" ), "x=third y=fourth", |
| 33 |
'async sub with extended keyword' ); |
| 34 |
} |
| 35 |
|
| 36 |
done_testing; |