Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add tests for sanity of .pick on Enums
  • Loading branch information
lizmat committed Mar 27, 2014
1 parent e81b345 commit 5859df5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion S32-list/pick.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 47;
plan 57;

=begin description
Expand Down Expand Up @@ -174,4 +174,19 @@ ok ('a'..'z').pick ~~ /\w/, 'Range.pick on non-Int range';
#?pugs skip 'hogs memory'
nok ([==] (^2**64).roll(10).map(* +& 15)), 'Range.pick has enough entropy';

# sanity on Enums
{
is Order.pick, any(Less,Same,More), 'simple pick on Enum type works';
is Order.pick(1), any(Less,Same,More), 'one pick on Enum type works';
is sort(Order.pick(*)), (Less,Same,More), 'all pick on Enum type works';
is sort(Order.pick(4)), (Less,Same,More), 'too many pick on Enum type works';
is Order.pick(0), (), 'zero pick on Enum type works';

is Less.pick, Less, 'simple pick on Enum is sane';
is Same.pick(1), Same, 'one pick on Enum is sane';
is More.pick(*), More, 'all pick on Enum is sane';
is Less.pick(4), Less, 'too many pick on Enum is sane';
is More.pick(0), (), 'zero pick on Enum is sane';
}

# vim: ft=perl6

0 comments on commit 5859df5

Please sign in to comment.