diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-03 22:04:42 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-03 22:05:20 +1300 |
commit | e857250bf4ecc47875433018b35f1a71120b3862 (patch) | |
tree | 2cbe3a6197bdeaff144bf67085b3492310535b83 | |
parent | Correct some awkward documentation (diff) | |
download | List-Breakdown-e857250bf4ecc47875433018b35f1a71120b3862.tar.gz (sig) List-Breakdown-e857250bf4ecc47875433018b35f1a71120b3862.zip |
Add some error testsv0.05
Ensure that bad inputs raise appropriate fatal errors.
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | lib/List/Filters.pm | 4 | ||||
-rw-r--r-- | t/errors.t | 17 | ||||
-rw-r--r-- | t/words.t | 6 |
4 files changed, 23 insertions, 5 deletions
@@ -2,4 +2,5 @@ lib/List/Filters.pm Makefile.PL MANIFEST README +t/errors.t t/words.t diff --git a/lib/List/Filters.pm b/lib/List/Filters.pm index 1e31f69..f85e9b3 100644 --- a/lib/List/Filters.pm +++ b/lib/List/Filters.pm @@ -16,7 +16,7 @@ use base qw(Exporter); our @EXPORT_OK = 'filter'; # Specify package version -our $VERSION = 0.04; +our $VERSION = 0.05; # Dispatch table of functions to handle different ref types for the spec # hashref's values @@ -89,7 +89,7 @@ List::Filters - Build list sublists matching conditions =head1 VERSION -Version 0.04 +Version 0.05 =head1 DESCRIPTION diff --git a/t/errors.t b/t/errors.t new file mode 100644 index 0000000..842c344 --- /dev/null +++ b/t/errors.t @@ -0,0 +1,17 @@ +#!perl -T + +use strict; +use warnings; +use utf8; + +use Test::More tests => 4; + +use List::Filters 'filter'; + +our $VERSION = 0.05; + +my @t = 1 .. 3; +is( eval { filter { a => undef }, @t } || undef, undef, 'error_notref_undef' ); +is( eval { filter { a => 'a' }, @t } || undef, undef, 'error_notref_def' ); +is( eval { filter { a => [] }, @t } || undef, undef, 'error_badref_array' ); +is( eval { filter { a => \{} }, @t } || undef, undef, 'error_badref_double' ); @@ -8,10 +8,10 @@ use Test::More tests => 1; use List::Filters 'filter'; -our $VERSION = 0.04; +our $VERSION = 0.05; -my @words = qw(foo bar baz quux wibble florb); -my $filters = { +my @words = qw(foo bar baz quux wibble florb); +my $filters = { all => sub { 1 }, has_b => sub { m/ b /msx }, has_w => sub { m/ w /msx }, |