Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,35 @@ | |||
use strict; | |||
use warnings; | |||
use 5.0100; | |||
use Test::More 0.94 tests => 3; | |||
|
|||
use Lingua::Boolean; | |||
|
|||
subtest 'yes' => sub { #YES | |||
my @yes = ('y', 'yes', 'ok', 'on', 'Y', 'YES', 'OK', 'ON', 1, 2); | |||
plan tests => scalar @yes * 2; | |||
foreach my $word (@yes) { | |||
ok(boolean($word), "$word is true"); | |||
is(boolean($word), boolean($word, 'en'), q{Default 'en' applied OK}); | |||
} | |||
}; | |||
|
|||
subtest 'no' => sub { # NO | |||
my @no = ('n', 'no', 'off', 'not ok', 'N', 'NO', 'OFF', 'NOTOK', 0); | |||
plan tests => scalar @no * 2; | |||
foreach my $word (@no) { | |||
ok(!boolean($word), "$word is false"); | |||
is(boolean($word), boolean($word, 'en'), q{Default 'en' applied OK}); | |||
} | |||
}; | |||
|
|||
subtest 'fail' => sub { # nonsense | |||
my @nonsense = qw(one two three); | |||
plan tests => scalar @nonsense; | |||
foreach my $word (@nonsense) { | |||
eval { | |||
boolean($word); | |||
}; | |||
like($@, qr{^'$word' isn't recognizable as either true or false}, "$word is nonsense"); | |||
} | |||
}; |