Permalink
Browse files

Add more sanity tests for Range.pick and Range.roll. Unfudge tests wh…

…ich are now quick in niecza.
  • Loading branch information...
1 parent 068fb14 commit 92c0f9613746e119969edf1af6852572739b4bb0 @colomon colomon committed Feb 21, 2012
Showing with 39 additions and 10 deletions.
  1. +29 −5 S32-list/pick.t
  2. +10 −5 S32-list/roll.t
View
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 37;
+plan 44;
=begin description
@@ -92,28 +92,52 @@ is (<a b c d>.pick(*).sort).Str, 'a b c d', 'pick(*) returns all the items in th
}
# ranges + pick
-#?niecza skip "Too slow"
+{
+ my %seen;
+ %seen{$_} = 1 for (1..100).pick(50);
+ is %seen.keys.elems, 50, 'Range.pick produces uniq elems';
+ ok (so 1 <= all(%seen.keys) <= 100), '... and all the elements are in range';
+}
+
+{
+ my %seen;
+ %seen{$_} = 1 for (1..300).pick(50);
+ is %seen.keys.elems, 50, 'Range.pick produces uniq elems';
+ ok (so 1 <= all(%seen.keys) <= 300), '... and all the elements are in range';
+}
+
+{
+ my %seen;
+ %seen{$_} = 1 for (1..50).pick(*);
+ is %seen.keys.elems, 50, 'Range.pick produces uniq elems';
+ ok (so 1 <= all(%seen.keys) <= 50), '... and all the elements are in range';
+}
+
+{
+ ok 1 <= (1..50).pick <= 50, 'Range.pick() works';
+}
+
{
my %seen;
%seen{$_} = 1 for (1..1_000_000).pick(50);
is %seen.keys.elems, 50, 'Range.pick produces uniq elems';
ok (so 1 <= all(%seen.keys) <= 1_000_000), '... and all the elements are in range';
}
-#?niecza skip "Too slow"
+
{
my %seen;
%seen{$_} = 1 for (1^..1_000_000).pick(50);
is %seen.keys.elems, 50, 'Range.pick produces uniq elems (lower exclusive)';
ok (so 1 < all(%seen.keys) <= 1_000_000), '... and all the elements are in range';
}
-#?niecza skip "Too slow"
+
{
my %seen;
%seen{$_} = 1 for (1..^1_000_000).pick(50);
is %seen.keys.elems, 50, 'Range.pick produces uniq elems (upper exclusive)';
ok (so 1 <= all(%seen.keys) < 1_000_000), '... and all the elements are in range';
}
-#?niecza skip "Too slow"
+
{
my %seen;
%seen{$_} = 1 for (1^..^1_000_000).pick(50);
View
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 35;
+plan 37;
=begin description
@@ -80,26 +80,31 @@ is (0, 1).roll(*).[^10].elems, 10, '.roll(*) returns at least ten elements';
}
# ranges + roll
-#?niecza skip "Too slow"
+{
+ ok 1 <= (1..1_000_000).roll() <= 1_000_000, 'no argument roll works';
+
+ my @matches := (1..1_000_000).roll(*);
+ ok (so 1 <= all(@matches[^100]) <= 1_000_000), 'the first 100 elems are in range';
+}
+
{
my @matches = (1..1_000_000).roll(20);
is @matches.elems, 20, 'right number of elements from Range.roll';
ok (so 1 <= all(@matches) <= 1_000_000), 'all the elems are in range';
}
-#?niecza skip "Too slow"
{
my @matches = (1^..1_000_000).roll(20);
is @matches.elems, 20, 'right number of elements from Range.roll (min exclusive)';
ok (so 1 < all(@matches) <= 1_000_000), 'all the elems are in range';
}
-#?niecza skip "Too slow"
+
{
my @matches = (1..^1_000_000).roll(20);
is @matches.elems, 20, 'right number of elements from Range.roll (max exclusive)';
ok (so 1 <= all(@matches) < 1_000_000), 'all the elems are in range';
}
-#?niecza skip "Too slow"
+
{
my @matches = (1^..^1_000_000).roll(20);
is @matches.elems, 20, 'right number of elements from Range.roll (both exclusive)';

0 comments on commit 92c0f96

Please sign in to comment.