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
|
#!/usr/bin/perl
use v5.14;
use warnings;
use Test2::V0;
BEGIN {
plan skip_all => "Syntax::Keyword::Match >= 0.08 is not available"
unless eval { require Syntax::Keyword::Match;
Syntax::Keyword::Match->VERSION( '0.08' ); };
plan skip_all => "Syntax::Operator::Equ is not available"
unless eval { require Syntax::Operator::Equ };
Syntax::Keyword::Match->import;
Syntax::Operator::Equ->import;
diag( "Syntax::Keyword::Match $Syntax::Keyword::Match::VERSION, " .
"Syntax::Operator::Equ $Syntax::Operator::Equ::VERSION" );
}
# literals
{
my $ok;
match("abc" : equ) {
case("abc") { $ok++ }
case("def") { fail('Not this one sorry'); }
}
ok( $ok, 'Literal match' );
}
# undef is not ""
{
my $ok;
match("" : equ) {
case(undef) { fail('Not this one sorry'); }
case("") { $ok++ }
}
ok( $ok, '"" did not match undef' );
undef $ok;
match(undef : equ) {
case("") { fail('Not this one sorry'); }
case(undef) { $ok++ }
}
ok( $ok, 'undef did not match ""' );
}
done_testing;
|