Lines 1-8
Link Here
|
1 |
|
1 |
|
2 |
use strict; |
2 |
use Modern::Perl; |
3 |
use warnings; |
|
|
4 |
|
3 |
|
5 |
use Test::More tests => 19; |
4 |
use Test::More tests => 22; |
|
|
5 |
use Test::Warn; |
6 |
|
6 |
|
7 |
BEGIN { use_ok( 'C4::Boolean', qw( true_p ) ); } |
7 |
BEGIN { use_ok( 'C4::Boolean', qw( true_p ) ); } |
8 |
|
8 |
|
Lines 23-28
is( true_p('yes'), '1', 'recognizes \'yes\' as true' );
Link Here
|
23 |
is( true_p('y'), '1', 'recognizes \'y\' as true' ); |
23 |
is( true_p('y'), '1', 'recognizes \'y\' as true' ); |
24 |
is( true_p('YES'), '1', 'verified case insensitivity' ); |
24 |
is( true_p('YES'), '1', 'verified case insensitivity' ); |
25 |
|
25 |
|
26 |
is( true_p(undef), undef, 'recognizes undefined as not boolean' ); |
26 |
my $result; |
27 |
is( true_p('foo'), undef, 'recognizes \'foo\' as not boolean' ); |
27 |
warning_like { $result = true_p(undef) } |
28 |
is( true_p([]), undef, 'recognizes a reference as not a boolean' ); |
28 |
qr/^The given value does not seem to be interpretable as a Boolean value/, |
|
|
29 |
'Invalid boolean (undef) raises warning'; |
30 |
is( $result, undef, 'recognizes undefined as not boolean' ); |
31 |
warning_like { $result = true_p('foo') } |
32 |
qr/^The given value does not seem to be interpretable as a Boolean value/, |
33 |
'Invalid boolean (\'foo\') raises warning'; |
34 |
is( $result, undef, 'recognizes \'foo\' as not boolean' ); |
35 |
warning_like { $result = true_p([]) } |
36 |
qr/^The given value does not seem to be interpretable as a Boolean value/, |
37 |
'Invalid boolean (reference) raises warning'; |
38 |
is( $result, undef, 'recognizes a reference as not a boolean' ); |
39 |
|
40 |
1; |
29 |
- |
|
|