Created
August 15, 2012 12:47
-
-
Save j1n3l0/3359867 to your computer and use it in GitHub Desktop.
testing List::Gather #perl #prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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