Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Created August 15, 2012 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j1n3l0/3359867 to your computer and use it in GitHub Desktop.
Save j1n3l0/3359867 to your computer and use it in GitHub Desktop.
testing List::Gather #perl #prototype
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment