Basic-Types-XS
view release on metacpan or search on metacpan
t/17-StrMatch.t view on Meta::CPAN
like($@, qr/value did not pass type constraint "StrMatch"/, 'non-matching string croaks');
$type = StrMatch(validate => qr/foo/, message => "Not foo!");
is($type->("foo bar"), "foo bar");
eval { $type->("bar") };
like($@, qr/Not foo!/, 'custom error message croaks');
$type = StrMatch(validate => qr/^.+$/);
is($type->("αβγ"), "αβγ", 'unicode letters match');
$type = StrMatch(validate => qr/^abc$/i);
is($type->("ABC"), "ABC", 'case-insensitive match');
$type = StrMatch(validate => qr/^$/);
is($type->(""), "", 'empty string matches empty pattern');
done_testing;
( run in 1.113 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )