-use strict;
-use C4::Boolean;
-
-use vars qw( @tests );
-use vars qw( $loaded );
-
-sub f ($) {
- my($x) = @_;
- my $it;
- # Returns either the value returned prefixed with 'OK:',
- # or the caught exception (string expected)
- local($@);
- eval {
- $it = 'OK:' . C4::Boolean::true_p($x);
- };
- if ($@) {
- $it = $@;
- $it =~ s/ at \S+ line \d+$\.\n//s;
- }
- return $it;
-}
-
-BEGIN {
- @tests = (
- [
- 'control',
- sub { C4::Boolean::INVALID_BOOLEAN_STRING_EXCEPTION },
- 'The given value does not seem to be interpretable as a Boolean value',
- undef
-
- # False strings
- ], [
- '"0"', \&f, 'OK:0', '0'
- ], [
- '"false"', \&f, 'OK:0', 'false'
- ], [
- '"off"', \&f, 'OK:0', 'off'
- ], [
- '"no"', \&f, 'OK:0', 'no'
-
- # True strings
- ], [
- '"1"', \&f, 'OK:1', '1'
- ], [
- '"true"', \&f, 'OK:1', 'true'
- ], [
- '"on"', \&f, 'OK:1', 'on'
- ], [
- '"yes"', \&f, 'OK:1', 'yes'
- ], [
- '"YES"', \&f, 'OK:1', 'YES' # verify case insensitivity