Skip to content

Commit 5859df5

Browse files
committed
Add tests for sanity of .pick on Enums
1 parent e81b345 commit 5859df5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

S32-list/pick.t

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use v6;
22

33
use Test;
44

5-
plan 47;
5+
plan 57;
66

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

177+
# sanity on Enums
178+
{
179+
is Order.pick, any(Less,Same,More), 'simple pick on Enum type works';
180+
is Order.pick(1), any(Less,Same,More), 'one pick on Enum type works';
181+
is sort(Order.pick(*)), (Less,Same,More), 'all pick on Enum type works';
182+
is sort(Order.pick(4)), (Less,Same,More), 'too many pick on Enum type works';
183+
is Order.pick(0), (), 'zero pick on Enum type works';
184+
185+
is Less.pick, Less, 'simple pick on Enum is sane';
186+
is Same.pick(1), Same, 'one pick on Enum is sane';
187+
is More.pick(*), More, 'all pick on Enum is sane';
188+
is Less.pick(4), Less, 'too many pick on Enum is sane';
189+
is More.pick(0), (), 'zero pick on Enum is sane';
190+
}
191+
177192
# vim: ft=perl6

0 commit comments

Comments
 (0)