Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add tests for roll and pick given a huge integer range.

  • Loading branch information...
commit 2d6c0122c640eb5dc08be0fd7e5fd804038a4cff 1 parent b093af3
@colomon colomon authored
Showing with 16 additions and 2 deletions.
  1. +8 −1 S32-list/pick.t
  2. +8 −1 S32-list/roll.t
View
9 S32-list/pick.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 44;
+plan 46;
=begin description
@@ -157,6 +157,13 @@ is (<a b c d>.pick(*).sort).Str, 'a b c d', 'pick(*) returns all the items in th
ok (so 1 < all(%seen.keys) < 1_000_000), '... and all the elements are in range';
}
+{
+ my %seen;
+ %seen{$_} = 1 for (1 .. (10**1000) ).pick(50);
+ is %seen.keys.elems, 50, 'Range.pick produces uniq elems in huge range';
+ ok (so 1 <= all(%seen.keys) <= 10**1000), '... and all the elements are in range';
+}
+
is (1..^2).pick, 1, 'pick on 1-elem range';
#?pugs todo
View
9 S32-list/roll.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 37;
+plan 39;
=begin description
@@ -111,6 +111,13 @@ is (0, 1).roll(*).[^10].elems, 10, '.roll(*) returns at least ten elements';
ok (so 1 < all(@matches) < 1_000_000), 'all the elems are in range';
}
+{
+ my @matches = (1..(10**1000)).roll(20);
+ is @matches.elems, 20, 'right number of elements from Range.roll, huge range';
+ ok (so 1 <= all(@matches) <= 10**1000), 'all the elems are in range';
+}
+
+
is (1..^2).roll, 1, '1-elem Range roll';
ok ('a' .. 'z').roll ~~ /\w/, 'Str-Range roll';

0 comments on commit 2d6c012

Please sign in to comment.
Something went wrong with that request. Please try again.