luqui has now implemented 'pick' in Pugs:
my @rand = .pick(3); is @rand.elems, 3, 'pick() should return the correct number of items'; ok all(@rand) ~~ any(@letters), '... and they should be in the letters';
But .pick should return unique elements. Let's test that:
my $compress = sub ($x) {
state $previous;
return $x ne $previous ?? ($previous = $x) !! ();
}
is map( $compress, 1 .. 1000 ).pick(999).elems, 999,
'pick() should be unique';
Yup. Lots of fun with Pugs :)
Note how I tested the junctions, though. The following not only ran 8 tests, but it also spewed a bunch of garbage all over my screen!
use v6-alpha;
use Test;
plan 1;
is 'b', any('a' .. 'h'), 'junctions should work';