diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-03 15:13:57 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-03 15:21:57 +1300 |
commit | 65a54c00d8083a96c18f02b7f43a4822e3f1fd9a (patch) | |
tree | 09b826ca77ccd7b9aad4cf830ff156eea8799499 /t | |
download | List-Breakdown-65a54c00d8083a96c18f02b7f43a4822e3f1fd9a.tar.gz (sig) List-Breakdown-65a54c00d8083a96c18f02b7f43a4822e3f1fd9a.zip |
First commit of List::Filtersv0.01
I'll add more Perl distribution infrastructure and tests as I learn more
about how that all works.
The README.markdown is just a manually converted README for now.
Diffstat (limited to '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' ); |