File Coverage

blib/lib/Text/Match/FastAlternatives.pm
Criterion Covered Total %
statement 19 20 95.0
branch 4 4 100.0
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             package Text::Match::FastAlternatives;
2              
3 8     8   126631 use strict;
  8         21  
  8         419  
4 8     8   48 use warnings;
  8         18  
  8         422  
5              
6             our $VERSION = '1.05';
7              
8 8     8   63 use XSLoader;
  8         15  
  8         297  
9             XSLoader::load(__PACKAGE__, $VERSION);
10              
11 8     8   40 use Carp ();
  8         16  
  8         1537  
12              
13             sub new {
14 27     27 1 170532 my ($class, @keywords) = @_;
15 27         68 for my $str (@keywords) {
16 1414 100       2540 Carp::croak("Undefined element in ", __PACKAGE__, "->new")
17             if !defined $str;
18 1413 100       3056 if (!utf8::valid($str)) {
19             # This suppresses two "malformed UTF-8" warnings that would
20             # otherwise be emitted by Carp when it constructs a message
21             # containing the arguments.
22 1     0   9 local $SIG{__WARN__} = sub {};
  0         0  
23 1         215 Carp::croak("Malformed UTF-8 in ", __PACKAGE__, "->new");
24             }
25             }
26 25         161984 return $class->new_instance(\@keywords);
27             }
28              
29             1;
30              
31             __END__