public
Created

testing List::Gather #perl #prototype

  • Download Gist
gistfile1.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
use 5.014;
use Test::Most;
use List::Gather;
 
sub evens_up_to {
my $max_number = shift;
my @even_numbers = gather {
for my $number ( 0 .. $max_number ) {
take $number unless $number % 2;
}
};
return @even_numbers;
}
 
is_deeply(
[ 0, 2, 4, 6, 8, 10 ],
[ evens_up_to(10) ],
'evens_up_to(10) => [ 0, 2, 4, 6, 8, 10 ]',
);
 
done_testing;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.