Koha/t/Boolean.t
Jonathan Druart b1ba7fac2c Bug 18292: Remove return 1 statements in tests
The test files do not need to return 1

Patch generated with:
perl -p -i -e "s/^1;\n//xsm" t/**/*.t

Test plan:
  git grep '^1;$' t/**/*.t
should not return any results

NOTE: does not fix C4/SIP/t, nor xt tests.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-08-15 12:17:42 -03:00

39 lines
1.7 KiB
Raku
Executable file

use Modern::Perl;
use Test::More tests => 22;
use Test::Warn;
BEGIN { use_ok( 'C4::Boolean', qw( true_p ) ); }
is( true_p('0'), '0', 'recognizes \'0\' as false' );
is( true_p('nil'), '0', 'recognizes \'nil\' as false' );
is( true_p('false'), '0', 'recognizes \'false\' as false' );
is( true_p('off'), '0', 'recognizes \'off\' as false' );
is( true_p('no'), '0', 'recognizes \'no\' as false' );
is( true_p('n'), '0', 'recognizes \'n\' as false' );
is( true_p('NO'), '0', 'verified case insensitivity' );
is( true_p('1'), '1', 'recognizes \'1\' as true' );
is( true_p('-1'), '1', 'recognizes \'-1\' as true' );
is( true_p('t'), '1', 'recognizes \'t\' as true' );
is( true_p('true'), '1', 'recognizes \'true\' as true' );
is( true_p('on'), '1', 'recognizes \'on\' as true' );
is( true_p('yes'), '1', 'recognizes \'yes\' as true' );
is( true_p('y'), '1', 'recognizes \'y\' as true' );
is( true_p('YES'), '1', 'verified case insensitivity' );
my $result;
warning_like { $result = true_p(undef) }
qr/^The given value does not seem to be interpretable as a Boolean value/,
'Invalid boolean (undef) raises warning';
is( $result, undef, 'recognizes undefined as not boolean' );
warning_like { $result = true_p('foo') }
qr/^The given value does not seem to be interpretable as a Boolean value/,
'Invalid boolean (\'foo\') raises warning';
is( $result, undef, 'recognizes \'foo\' as not boolean' );
warning_like { $result = true_p([]) }
qr/^The given value does not seem to be interpretable as a Boolean value/,
'Invalid boolean (reference) raises warning';
is( $result, undef, 'recognizes a reference as not a boolean' );