Skip to content

Commit 2d6c012

Browse files
committed
Add tests for roll and pick given a huge integer range.
1 parent b093af3 commit 2d6c012

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

S32-list/pick.t

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

33
use Test;
44

5-
plan 44;
5+
plan 46;
66

77
=begin description
88
@@ -157,6 +157,13 @@ is (<a b c d>.pick(*).sort).Str, 'a b c d', 'pick(*) returns all the items in th
157157
ok (so 1 < all(%seen.keys) < 1_000_000), '... and all the elements are in range';
158158
}
159159

160+
{
161+
my %seen;
162+
%seen{$_} = 1 for (1 .. (10**1000) ).pick(50);
163+
is %seen.keys.elems, 50, 'Range.pick produces uniq elems in huge range';
164+
ok (so 1 <= all(%seen.keys) <= 10**1000), '... and all the elements are in range';
165+
}
166+
160167
is (1..^2).pick, 1, 'pick on 1-elem range';
161168

162169
#?pugs todo

S32-list/roll.t

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

33
use Test;
44

5-
plan 37;
5+
plan 39;
66

77
=begin description
88
@@ -111,6 +111,13 @@ is (0, 1).roll(*).[^10].elems, 10, '.roll(*) returns at least ten elements';
111111
ok (so 1 < all(@matches) < 1_000_000), 'all the elems are in range';
112112
}
113113

114+
{
115+
my @matches = (1..(10**1000)).roll(20);
116+
is @matches.elems, 20, 'right number of elements from Range.roll, huge range';
117+
ok (so 1 <= all(@matches) <= 10**1000), 'all the elems are in range';
118+
}
119+
120+
114121
is (1..^2).roll, 1, '1-elem Range roll';
115122
ok ('a' .. 'z').roll ~~ /\w/, 'Str-Range roll';
116123

0 commit comments

Comments
 (0)