Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[bag.t] Use .roll instead of .pick with :replace.

  • Loading branch information...
commit ea8f32d7a1df64bdfb9a8bb190cb3efd5a816001 1 parent 8e4955e
Kodi Arfer authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 S02-builtin_data_types/bag.t
View
14 S02-builtin_data_types/bag.t
@@ -74,11 +74,17 @@ sub showkv($x) {
is +@a, 3, '.pick(*) returns the right number of items';
is @a.grep(* eq 'a').elems, 1, '.pick(*) (1)';
is @a.grep(* eq 'b').elems, 2, '.pick(*) (2)';
+}
+
+# L<S32::Containers/Bag/roll>
+
+{
+ my $b = bag <a b b>;
- @a = $b.pick: 100, :replace;
- is +@a, 100, '.pick(100, :replace) returns 100 items';
- ok 2 < @a.grep(* eq 'a') < 75, '.pick(100, :replace) (1)';
- ok @a.grep(* eq 'a') + 2 < @a.grep(* eq 'b'), '.pick(100, :replace) (2)';
+ @a = $b.roll: 100;
+ is +@a, 100, '.roll(100,) returns 100 items';
+ ok 2 < @a.grep(* eq 'a') < 75, '.roll(100) (1)';
+ ok @a.grep(* eq 'a') + 2 < @a.grep(* eq 'b'), '.roll(100) (2)';
}
# vim: ft=perl6
Please sign in to comment.
Something went wrong with that request. Please try again.