Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Last active January 2, 2016 20:19
Show Gist options
  • Save hoelzro/8355699 to your computer and use it in GitHub Desktop.
Save hoelzro/8355699 to your computer and use it in GitHub Desktop.
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;
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