Last active
January 2, 2016 20:19
-
-
Save hoelzro/8355699 to your computer and use it in GitHub Desktop.
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 v6; | |
use Test; | |
sub expanded-version { | |
my @values = <foo bar baz>; | |
my %possible-values = ( | |
foo => (1..9).list, | |
bar => (2..9).list, | |
baz => (3..9).list, | |
); | |
for @values -> $value { | |
my @matches = %possible-values{$value}.grep: { | |
$_ %% 2 | |
}; | |
%possible-values{$value} = @matches; | |
} | |
is(%possible-values<foo>, [2, 4, 6, 8]); | |
} | |
sub dot-equals-version { | |
my @values = <foo bar baz>; | |
my %possible-values = ( | |
foo => (1..9).list, | |
bar => (2..9).list, | |
baz => (3..9).list, | |
); | |
for @values -> $value { | |
%possible-values{$value} .= grep: { | |
$_ %% 2 | |
}; | |
} | |
say %possible-values.perl; | |
is(%possible-values<foo>, [2, 4, 6, 8]); | |
} | |
plan 2; | |
expanded-version; | |
dot-equals-version; |
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
1..2 | |
ok 1 - | |
("foo" => ().list.item, "bar" => ().list.item, "baz" => ().list.item).hash | |
not ok 2 - | |
# got: '' | |
# expected: '2 4 6 8' | |
# Looks like you failed 1 tests of 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment