| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
use v5.14; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use Test2::V0; |
| 7 |
|
| 8 |
use lib "t"; |
| 9 |
use testcase "t::pieces"; |
| 10 |
|
| 11 |
BEGIN { $^H{"t::pieces/permit"} = 1; } |
| 12 |
|
| 13 |
{ |
| 14 |
my $ret = pieceident foobar; |
| 15 |
is( $ret, "foobar", 'result of pieceident' ); |
| 16 |
|
| 17 |
ok( !defined eval 'pieceident', |
| 18 |
'pieceident complains of missing ident' ); |
| 19 |
like( $@, qr/^Expected an identifier at /, 'message from missing ident' ); |
| 20 |
} |
| 21 |
|
| 22 |
{ |
| 23 |
my $ret = pieceident_opt present; |
| 24 |
is( $ret, "present", 'result of pieceident_opt with ident' ); |
| 25 |
|
| 26 |
$ret = pieceident_opt; |
| 27 |
ok( !defined $ret, 'result of pieceident_opt without' ); |
| 28 |
} |
| 29 |
|
| 30 |
{ |
| 31 |
my $ret = piecepkg Bar::Foo; |
| 32 |
is( $ret, "Bar::Foo", 'result of piecepkg' ); |
| 33 |
|
| 34 |
ok( !defined eval 'piecepkg', |
| 35 |
'piecepkg complains of missing packagename' ); |
| 36 |
like( $@, qr/^Expected a package name at /, 'message from missing packagename' ); |
| 37 |
} |
| 38 |
|
| 39 |
done_testing; |