diff options
Diffstat (limited to 't/words.t')
-rw-r--r-- | t/words.t | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/t/words.t b/t/words.t new file mode 100644 index 0000000..bdefa43 --- /dev/null +++ b/t/words.t @@ -0,0 +1,39 @@ +#!perl -T + +use strict; +use warnings; +use utf8; + +use Test::More tests => 1; + +use List::Filters 'filter'; + +our $VERSION = 0.01; + +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 }, + length => { + 3 => sub { length == 3 }, + 4 => sub { length == 4 }, + long => sub { length > 4 }, + }, + has_ba => qr/ba/msx, +}; +my %filtered = filter $filters, @words; + +my %expected = ( + all => [qw(foo bar baz quux wibble florb)], + has_b => [qw(bar baz wibble florb)], + has_w => [qw(wibble)], + length => { + 3 => [qw(foo bar baz)], + 4 => [qw(quux)], + long => [qw(wibble florb)], + }, + has_ba => [qw(bar baz)], +); + +is_deeply( \%filtered, \%expected, 'words' ); |