blib/lib/Data/Password/Check.pm

filter: Statementstmt 86.7% 111 / 128 Branchbran 74.2% 49 / 66 Conditioncond 58.3% 14 / 24 MC/DCmcdc 33.3% 5 / 15 Subroutinesub 100% 16 / 16 Podpod 100% 3 / 3 totaltotal 78.5% 198 / 252 CC 46 SCAR 20.0
CC
46
Cov
80%
_check_diverse_characters
12.6
_do_checks
11.8
_check_silly
9.4
CRAP 7.4
↑ Summary
1 package Data::Password::Check;
2 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 our $VERSION = '0.08';
7  
8 =head1 NAME
9  
10 Data::Password::Check - sanity check passwords
11  
12 =head1 DESCRIPTION
13  
14 Users can be lazy. If you're a perl programmer this is a good thing. If you're
15 choosing a password this is a bad thing.
16  
17 This module performs some sanity checks on passwords. Details on checks than
18 can be performed are described below.
19  
20 =head1 SYNOPSIS
21  
22 Basic use of the module is as follows:
23  
24 use Data::Password::Check;
25  
26 # check a password
27 my $pwcheck = Data::Password::Check->check({
28 'password' => $some_password
29 });
30  
31 # did we have any errors?
32 if ($pwcheck->has_errors) {
33 # print the errors
34 print(
35 join("\n", @{ $pwcheck->error_list }),
36 "\n"
37 );
38 }
39  
40 =cut
41  
42 =head1 PUBLIC METHODS
43  
44 These methods are publically available. Use them to your heart's content.
45  
46 =head2 check($proto,$options)
47  
48 This is the main function for this module. You must pass one mandatory value in
49 the $options hash-reference - a password:
50  
51 # check a password
52 $result = Data::Password::Check->check({'password' => $pwd_to_check});
53  
54 There are other options that may be passed to invoke further password tests if
55 required:
56  
57 =over 4
58  
59 =item * tests
60  
61 set this to a list of test names to replace the list of tests performed by the module
62  
63 e.g. tests =E<gt> [ 'length' ] will make the module perfoem the length check only
64  
65 =item * tests_append
66  
67 set this to a list of additional tests to perform. This is useful if you want
68 to call more tests than are in the default list, or to include your own tests
69 when inheriting from this module.
70  
71 e.g. test =E<gt> [ 'mytest1', 'mytest2' ] will make the module perform two
72 extra tests (assuming they exist) mytest1 and mytest2.
73  
74 =back
75  
76 =cut
77 51 ▶sub check($$) {
Subroutine check: called CC=4 SCAR=15.6
Pod documented
78 51 my ($proto, $options) = @_;
79 51 my ($self, $class);
80  
81 51 ▶ $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
0510
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
82 51 $self = {};
83 51 bless $self, $class;
84  
85 # make sure $options is a hash-reference
86 51 ▶ unless (ref($options) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $options eq "HASH") 0 51 51
87 0 Carp::carp("You need to pass a hash-reference of options to check()");
88 0 return undef;
89 }
90  
91 # make sure we at least have a password value
92 51 ▶ unless (exists $options->{'password'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $options->{"password"}) 0 51 51
93 0 Carp::carp("You need to supply a password to check()!");
94 0 return undef;
95 }
96  
97 # store the password so it's easier to refer to
98 # (i.e. $self->{'password'} rather than $self->{'options'}{'password'})
99 51 $self->{'password'} = $options->{'password'};
100  
101 # make a copy of the incomong options
102 51 $self->{'options'} = $options;
103  
104 # perform the password checks
105 51 $self->_do_checks;
106  
107 51 return $self;
108 }
109  
110 =head2 has_errors($class)
111  
112 This function is used to determine if there were any errors found while sanity
113 checking the supplied password. It does not return the errors themselves.
114  
115 Returns B<1> if there were errors, B<0> otherwise
116  
117 =cut
118 155 ▶sub has_errors($) {
Subroutine has_errors: called CC=2 SCAR=7.1
Pod documented
119 155 my ($self) = @_;
120 155 ▶ return (exists $self->{'_error_count'} and $self->{'_error_count'} > 0);
Condition66%2/3
exists $self->{'_error_count'} && $self->{'_error_count'} > 0
!ll&&!rl&&r
69086
MC/DC50%1/2
exists $self->{'_error_count'} && $self->{'_error_count'} > 0
exists $self->{'_error_count'} $self->{'_error_count'} > 0
Truth table66%2/3
A && B
A= exists $self->{'_error_count'}B= $self->{'_error_count'} > 0
ABresult
0X0
100
111
121 }
122  
123 =head2 error_list($class)
124  
125 This function returns an array-reference to a list of the error messages.
126 If there are no errors B<undef> is returned.
127  
128 =cut
129 24 ▶sub error_list($) {
Subroutine error_list: called CC=2 SCAR=7.6
Pod documented
130 24 my ($self) = @_;
131 24 ▶ if ($self->has_errors) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_errors) 24 0 24
132 24 return $self->{'_errors'};
133 }
134  
135 0 return undef;
136 }
137  
138  
139 =head1 AVAILABLE CHECKS
140  
141 By default the module will perform all checks listed below. You can limit the
142 number of checks by passing a list of desired tests via the B<tests> option
143 when calling check(). e.g.
144  
145 Data::Password::Check->check({
146 ...
147 'tests' => [ 'length' ], # check only that the password meets a minimum-length requirement
148 ...
149 });
150  
151 =cut
152  
153 =head2 alphanumeric_only
154  
155 Make sure the password only contains a-z, A-Z and 0-9 characters.
156  
157 =cut
158 3 ▶sub _check_alphanumeric_only($) {
Subroutine _check_alphanumeric_only: called CC=2 SCAR=6.9
159 3 my ($self) = @_;
160  
161 # make sure the password only contains alphanumeric characters
162 3 ▶ unless ($self->{'password'} =~ /^[[:alnum:]]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"password"} =~ /^[[:alnum:]]+$/) 2 1 3
163 2 $self->_add_error("Your password may only contain alphanumeric characters (A-Z, a-z and 0-9)");
164 }
165 }
166  
167 =head2 alphanumeric
168  
169 Make sure the password contains one of each from the following sets: a-z, A-Z and 0-9
170  
171 =cut
172 7 ▶sub _check_alphanumeric($) {
Subroutine _check_alphanumeric: called CC=4 SCAR=14.1
173 7 my ($self) = @_;
174  
175 # make sure the password contains one lower case and one uppercase character, and one digit - at least
176 # tr// seems the best way (at the moment) to check this requirement
177 7 ▶ unless (
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"password"} =~ tr/a-z// and $self->{"password"} =~ tr/A-Z// and $self->{"password"} =~ tr/0-9//) 3 4 7
Condition66%4/6
$self->{"password"} =~ tr/a-z// and $self->{"password"} =~ tr/A-Z// and $self->{"password"} =~ tr/0-9//
!ll&&!rl&&r
304
$self->{"password"} =~ tr/a-z// and $self->{"password"} =~ tr/A-Z//
!ll&&!rl&&r
304
MC/DC33%1/3
$self->{"password"} =~ tr/a-z// and $self->{"password"} =~ tr/A-Z// and $self->{"password"} =~ tr/0-9//
$self->{"password"} =~ tr/a-z// $self->{"password"} =~ tr/A-Z// $self->{"password"} =~ tr/0-9//
Truth table50%2/4
A and B and C
A= $self->{"password"} =~ tr/a-z//B= $self->{"password"} =~ tr/A-Z//C= $self->{"password"} =~ tr/0-9//
ABCresult
0XX0
10X0
1100
1111
178 ($self->{'password'} =~ tr/a-z//) and
179 ($self->{'password'} =~ tr/A-Z//) and
180 ($self->{'password'} =~ tr/0-9//) ) {
181 3 $self->_add_error("Your password must contain mixed-case letters and numbers");
182 }
183 }
184  
185 =head2 length
186  
187 Make sure the password it at least 6 characters long. If B<min_length> was passed
188 as an option to check(), this value will be used instead, assuming it's a
189 positive integer.
190  
191 =cut
192 13 ▶sub _check_length($) {
Subroutine _check_length: called CC=8 SCAR=20.8
193 13 my ($self) = @_;
194 13 my $min_length = 6;
195  
196 # does the user want a different length
197 13 ▶ if (exists $self->{'options'}{'min_length'} and not defined $self->{'options'}{'min_length'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->{'options'}{'min_length'} and not defined $self->{'options'}{'min_length'}) { } 1 12 13
elsif (exists $self->{'options'}{'min_length'} and defined $self->{'options'}{'min_length'}) { } 7 10 17
Condition100%3/3
exists $self->{"options"}{"min_length"} and not defined $self->{"options"}{"min_length"}
!ll&&!rl&&r
571
MC/DC100%2/2
exists $self->{"options"}{"min_length"} and not defined $self->{"options"}{"min_length"}
exists $self->{"options"}{"min_length"} not defined $self->{"options"}{"min_length"}
Truth table100%3/3
A and not(B)
A= exists $self->{"options"}{"min_length"}B= not defined $self->{"options"}{"min_length"}
ABresult
0X0
100
111
198 # issue a warning
199 1 Carp::cluck("min_length argument must be a defined value");
200 # return undef
201 1 return undef;
202 }
203 ▶ elsif (exists $self->{'options'}{'min_length'} and defined $self->{'options'}{'min_length'}) {
Condition66%2/3
exists $self->{"options"}{"min_length"} and defined $self->{"options"}{"min_length"}
!ll&&!rl&&r
507
MC/DC50%1/2
exists $self->{"options"}{"min_length"} and defined $self->{"options"}{"min_length"}
exists $self->{"options"}{"min_length"} defined $self->{"options"}{"min_length"}
Truth table66%2/3
A and B
A= exists $self->{"options"}{"min_length"}B= defined $self->{"options"}{"min_length"}
ABresult
0X0
100
111
204 # is it a positive, on-zero, integer?
205 7 ▶ if ($self->{'options'}{'min_length'} =~ /^[1-9]\d*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'options'}{'min_length'} =~ /^[1-9]\d*$/) { } 4 3 7
206 4 $min_length = $self->{'options'}{'min_length'};
207 }
208 else {
209 # issue a warning
210 3 Carp::cluck("min_length argument [$self->{'options'}{'min_length'} isn't a positive, non-zero, integer");
211 # return undef
212 3 return undef;
213 }
214 }
215  
216 # if password is undefined, set it to '', so we aren't comparing undef with anything
217 9 ▶ unless (defined $self->{'password'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"password"}) 1 8 9
218 1 $self->{'password'} = '';
219 }
220  
221 # now we can check that the password meets the minimum length requirement
222 9 ▶ if (length($self->{'password'}) >= $min_length) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{'password'} >= $min_length) { } 6 3 9
223 6 return 1;
224 }
225 else {
226 # store a failure message
227 3 $self->_add_error("The password must be at least $min_length characters");
228 }
229 }
230  
231 =head2 mixed_case
232  
233 Make sure the password is mixes case, i.e. not all lower case, nor all upper case
234  
235 =cut
236 12 ▶sub _check_mixed_case($) {
Subroutine _check_mixed_case: called CC=2 SCAR=6.9
237 12 my ($self) = @_;
238  
239 # does the password contain at least one lowercase and one uppercase character?
240 12 ▶ unless ($self->{'password'} =~ /(?:[A-Z].*[a-z]|[a-z].*[A-Z])/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"password"} =~ /(?:[A-Z].*[a-z]|[a-z].*[A-Z])/) 8 4 12
241 8 $self->_add_error("Your password must contain a mixture of lower and upper-case letters");
242 }
243 }
244  
245 =head2 diverse_characters
246  
247 Make sure the password is contains a diversity of character group types
248 (uppercase, lower case, digits, symbols). By default, at least one character
249 group must be present in the password (which any password will satisfy -
250 override this to invoke the test). If B<diversity_required> was passed
251 as an option to check(), this value will be used instead.
252  
253 =cut
254 10 ▶sub _check_diverse_characters($) {
Subroutine _check_diverse_characters: called CC=9 SCAR=25.4
255 10 my ($self) = @_;
256 10 my $diversity_required = 1;
257 # does the user want a different diversity?
258 10 ▶ if (exists $self->{'options'}{'diversity_required'} and not defined $self->{'options'}{'diversity_required'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->{'options'}{'diversity_required'} and not defined $self->{'options'}{'diversity_required'}) { } 0 10 10
elsif (exists $self->{'options'}{'diversity_required'} and defined $self->{'options'}{'diversity_required'}) { } 10 0 10
Condition33%1/3
exists $self->{"options"}{"diversity_required"} and not defined $self->{"options"}{"diversity_required"}
!ll&&!rl&&r
0100
MC/DC0%0/2
exists $self->{"options"}{"diversity_required"} and not defined $self->{"options"}{"diversity_required"}
exists $self->{"options"}{"diversity_required"} not defined $self->{"options"}{"diversity_required"}
Truth table33%1/3
A and not(B)
A= exists $self->{"options"}{"diversity_required"}B= not defined $self->{"options"}{"diversity_required"}
ABresult
0X0
100
111
259 # issue a warning
260 0 Carp::cluck("diversity_required argument must be a defined value");
261 0 return undef;
262 }
263 ▶ elsif (exists $self->{'options'}{'diversity_required'} and defined $self->{'options'}{'diversity_required'}) {
Condition33%1/3
exists $self->{"options"}{"diversity_required"} and defined $self->{"options"}{"diversity_required"}
!ll&&!rl&&r
0010
MC/DC0%0/2
exists $self->{"options"}{"diversity_required"} and defined $self->{"options"}{"diversity_required"}
exists $self->{"options"}{"diversity_required"} defined $self->{"options"}{"diversity_required"}
Truth table33%1/3
A and B
A= exists $self->{"options"}{"diversity_required"}B= defined $self->{"options"}{"diversity_required"}
ABresult
0X0
100
111
264 # is it in range?
265 10 ▶ if ($self->{'options'}{'diversity_required'} =~ /^[1-4]\d*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'options'}{'diversity_required'} =~ /^[1-4]\d*$/) { } 10 0 10
266 10 $diversity_required = $self->{'options'}{'diversity_required'};
267 }
268 else {
269 # issue a warning
270 0 Carp::cluck("diversity_required argument [$self->{'options'}{'diversity_required'} isn't in the range 1-4");
271 0 return undef;
272 }
273 }
274
275 10 my $group_count = 0;
276 10 foreach my $pattern (qw([A-Z] [a-z] [0-9] [^A-Za-z0-9]))
277 {
278 40 ▶ if ($self->{'password'} =~ /$pattern/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"password"} =~ /$pattern/) 18 22 40
279 18 $group_count++;
280 }
281 }
282
283 # Are enough character groups used to satisfy diversity requirements?
284 10 ▶ if ($group_count < $diversity_required) {
Branch: 1 branch
BranchTrueFalseTotal
if ($group_count < $diversity_required) 3 7 10
285 3 $self->_add_error("Your password must contain a good mix of character types, from at least $diversity_required of the following categories: Uppercase letters, lowercase letters, numeral, symbols.");
286 }
287 }
288  
289 =head2 silly
290  
291 Make sure the password isn't a known silly word (e.g 'password' is a bad choice
292 for a password).
293  
294 The default list contains I<qwerty>, and I<password> only. You may choose to
295 replace this list of words or to add your own to the end of the list.
296  
297 If you wish to B<replace> the list of silly-words, you should pass them in via
298 the options when calling check(), as 'silly_words'. e.g.
299  
300 Data::Password::Check->check({
301 ...
302 'silly_words' => [ 'my', 'silly', 'words' ],
303 ...
304 });
305  
306 If you would like to add words to the existing list, you should pass them in
307 via the 'silly_words_append' option when calling check(). e.g.
308  
309 Data::Password::Check->check({
310 ...
311 'silly_words_append' => [ 'more', 'silly', 'words' ],
312 ...
313 });
314  
315 All matching is case-insensitive, and if you choose to append words, duplicates
316 will be omitted.
317  
318 =cut
319 13 ▶sub _check_silly($) {
Subroutine _check_silly: called CC=9 SCAR=22.4
320 13 my ($self) = @_;
321 # default words we don't want people to use as passwords
322 13 my @silly_words = qw{
323 password
324 qwerty
325 };
326 # does the user want to REPLACE the current list of words
327 13 ▶ if (exists $self->{'options'}{'silly_words'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"options"}{"silly_words"}) 6 7 13
328 # is it an array-ref?
329 6 ▶ if (ref($self->{'options'}{'silly_words'}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'options'}{'silly_words'} eq 'ARRAY') { } 6 0 6
330 # override the default checks
331 6 @silly_words = @{ $self->{'options'}{'silly_words'} };
332 }
333 else {
334 0 Carp::carp("The 'silly_words' option must be an array-reference. Continuing with default list.");
335 }
336 }
337  
338 # does the user want to ADD to the existing list of word
339 13 ▶ if (exists $self->{'options'}{'silly_words_append'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"options"}{"silly_words_append"}) 2 11 13
340 # is it an array-ref?
341 2 ▶ if (ref($self->{'options'}{'silly_words_append'}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'options'}{'silly_words_append'} eq 'ARRAY') { } 2 0 2
342 # push the words onto the end of the list
343 # make sure we don't already have the word
344 2 foreach my $append (@{ $self->{'options'}{'silly_words_append'} }) {
345 6 ▶ unless ( grep { /^$append$/ } @silly_words ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {/^$append$/;} @silly_words) 6 0 6
346 6 push @silly_words, $append;
347 }
348 }
349 }
350 else {
351 0 Carp::carp("The 'silly_words' option must be an array-reference. Continuing with default list.");
352 }
353 }
354  
355 # now we loop through the silly_words and make sure our password doesn't match them
356 13 foreach my $silly (@silly_words) {
357 # do a case-insensitive match, but look for the whole string
358 35 ▶ if ($self->{'password'} =~ /^$silly$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"password"} =~ /^$silly$/i) 6 29 35
359 6 $self->_add_error("You may not use '$self->{'password'}' as your password");
360 }
361 }
362 }
363  
364 =head2 repeated
365  
366 Make sure the password isn't a single character repeated, e.g. 'aaaaaaaaaa'.
367  
368 =cut
369 9 ▶sub _check_repeated($) {
Subroutine _check_repeated: called CC=2 SCAR=6.9
370 9 my ($self) = @_;
371  
372 # is the password made up of the same character repeated?
373 9 ▶ if ($self->{'password'} =~ /^(.)\1+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"password"} =~ /^(.)\1+$/) 3 6 9
374 3 $self->_add_error("You cannot use a single repeated character as a password");
375 }
376 }
377  
378  
379 =head1 PRIVATE METHODS
380  
381 These methods are private to this module. If you choose to use them outside the
382 module, all bets are off.
383  
384 =head2 _do_checks($self)
385  
386 This function calls each required test in turn. It's an internal function
387 called within check().
388  
389 =cut
390 51 ▶sub _do_checks($) {
Subroutine _do_checks: called CC=10 SCAR=24.7
391 51 my ($self) = @_;
392 51 my (@checks, $fn, $custom_checks);
393  
394 # the list of checks to make
395 51 @checks = qw(
396 length
397 mixed_case
398 silly
399 repeated
400 );
401 # custom_checks defaults to false
402 51 $custom_checks = 0;
403  
404 # allow the user to override the list of checks
405 # we require the 'tests' option to exist, and to be an array-reference
406 51 ▶ if (exists $self->{'options'}{'tests'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"options"}{"tests"}) 46 5 51
407 46 ▶ if (ref($self->{'options'}{'tests'}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'options'}{'tests'} eq 'ARRAY') { } 46 0 46
408 # override the default checks
409 46 @checks = @{ $self->{'options'}{'tests'} };
410 # set the custom_checks flag
411 46 $custom_checks = 1;
412 }
413 else {
414 0 Carp::carp("The 'tests' option must be an array-reference. Continuing with default tests.");
415 }
416 }
417  
418 # allow the user to override the list of checks
419 # we require the 'tests' option to exist, and to be an array-reference
420 51 ▶ if (exists $self->{'options'}{'append_tests'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"options"}{"append_tests"}) 1 50 51
421 1 ▶ if (ref($self->{'options'}{'append_tests'}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'options'}{'append_tests'} eq 'ARRAY') { } 1 0 1
422 # override the default checks
423 1 @checks = (@checks, @{ $self->{'options'}{'append_tests'} });
424 # set the custom_checks flag
425 1 $custom_checks = 1;
426 }
427 else {
428 0 Carp::carp("The 'append_tests' option must be an array-reference. Continuing with default tests.");
429 }
430 }
431  
432 # loop through the checks we would like to do
433 51 foreach my $test (@checks) {
434 # set the name of the function we'd like to call
435 67 my $fn = "_check_${test}";
436 # if we can run the function, do so
437 67 ▶ if ($self->can("_check_${test}")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can("_check_$test")) { } 67 0 67
438 67 ▶ unless (defined $self->$fn) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->$fn) 4 63 67
439 # make a note that we skipped the test
440 4 push @{ $self->{'skipped_tests'} }, $test;
441 4 ▶ Carp::carp("skipped test '$test' due to errors") if $self->{'DEBUG'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"DEBUG"} 0 4 4
442 };
443 }
444 # otherwise warn that we're trying to call something
445 # that we can't find
446 else {
447 # warn or carp, depending on whether we've got a custom
448 # list of tests
449 0 ▶ if ($custom_checks) {
Branch: 1 branch
BranchTrueFalseTotal
if ($custom_checks) { } 0 0 0
450 0 Carp::carp("The are no password checks available for '$test'");
451 }
452 else {
453 0 warn "no such password check function: $fn()";
454 }
455 }
456 }
457 }
458  
459 =head2 _add_error($class,$message)
460  
461 This function is used to add an error message to the internal store.
462 The errors can later be retrieved using the B<error_list()> method.
463  
464 =cut
465 28 ▶sub _add_error($$) {
Subroutine _add_error: called CC=1 SCAR=0.0
466 28 my ($self, $message) = @_;
467  
468 # increase the count of errors we've added
469 28 $self->{'_error_count'} ++;
470  
471 # add the error message to a list of messages
472 28 push @{ $self->{'_errors'} }, $message;
473 }
474  
475 =head2 _skipped_test($class,$testname)
476  
477 This function exists so that it's possible to work out if a test was skipped
478 because "something went wrong" - usually because of an invalid option passed in
479 via the check() options.
480  
481 This function was written to enable some tests in the "make test" phase of
482 installing the module.
483  
484 =cut
485 4 ▶sub _skipped_test($$) {
Subroutine _skipped_test: called CC=3 SCAR=11.6
486 4 my ($self, $testname) = @_;
487  
488 # do we have a list of skipped tests?
489 4 ▶ if (exists $self->{'skipped_tests'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"skipped_tests"}) 4 0 4
490 # does $testname exist in the list?
491 4 ▶ if (grep { /^$testname$/ } @{ $self->{'skipped_tests'} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {/^$testname$/;} @{$$self{"skipped_tests"};}) 4 0 4
492 4 return 1;
493 }
494 }
495  
496 # no indication that we skipped the test
497 0 return 0;
498 }
499  
500 =head1 AUTHOR
501  
502 Chisel Wright C<< <chiselwright@berlios.de> >>
503  
504 =head1 CONTRIBUTORS
505  
506 Dermot McNally C<< CPANID: DERMOT >>
507  
508 =head1 PROJECT HOMEPAGE
509  
510 This project can be found at BerliOS:
511 L<http://developer.berlios.de/projects/d-p-check/>
512  
513 =head1 COPYRIGHT AND LICENCE
514  
515 Copyright (C) 2005-2007 by Chisel Wright
516  
517 This library is free software; you can redistribute it and/or modify
518 it under the same terms as Perl itself, either Perl version 5.8.2 or,
519 at your option, any later version of Perl 5 you may have available.
520  
521 =cut
522  
523 # be true
524 9 1;
525  
526 __END__
↑ Summary