Permalink
Browse files

pugs fudge

  • Loading branch information...
1 parent 87dea8d commit 30d3be920e5f5b2b9b201b0cf8358382daf3d8b2 @coke coke committed Apr 4, 2012
Showing with 33 additions and 3 deletions.
  1. +21 −1 S32-list/pick.t
  2. +12 −2 S32-scalar/defined.t
View
@@ -17,19 +17,22 @@ L<"http://groups.google.com/group/perl.perl6.language/tree/browse_frm/thread/24e
# L<S32::Containers/List/=item pick>
my @array = <a b c d>;
+#?pugs skip "autothread"
ok ?(@array.pick eq any <a b c d>), "pick works on arrays";
#?niecza skip '().pick === Nil'
+#?pugs skip 'Nil'
ok ().pick === Nil, '.pick on the empty list is Nil';
my @arr = <z z z>;
ok ~(@arr.pick(2)) eq 'z z', 'method pick with $num < +@values';
ok ~(@arr.pick(4)) eq 'z z z', 'method pick with $num > +@values';
-#?pugs 2 todo 'feature'
+#?pugs 2 skip 'NYI'
is pick(2, @arr), <z z>, 'sub pick with $num < +@values, implicit no-replace';
is pick(4, @arr), <z z z>, 'sub pick with $num > +@values';
+#?pugs skip '.Str'
is (<a b c d>.pick(*).sort).Str, 'a b c d', 'pick(*) returns all the items in the array (but maybe not in order)';
{
@@ -40,6 +43,7 @@ is (<a b c d>.pick(*).sort).Str, 'a b c d', 'pick(*) returns all the items in th
'pick(*) returned the items of the array in a random order');
}
+#?pugs skip "autothreading"
{
# Test that List.pick doesn't flatten array refs
ok ?([[1, 2], [3, 4]].pick.join('|') eq any('1|2', '3|4')), '[[1,2],[3,4]].pick does not flatten';
@@ -51,6 +55,7 @@ is (<a b c d>.pick(*).sort).Str, 'a b c d', 'pick(*) returns all the items in th
'.pick() returns something can be used as single scalar';
}
+#?pugs skip 'pick not defined: VNum Infinity'
{
my @a = 1..100;
my @b = pick(*, @a);
@@ -63,27 +68,34 @@ is (<a b c d>.pick(*).sort).Str, 'a b c d', 'pick(*) returns all the items in th
my @a = 1..100;
isa_ok @a.pick, Int, "picking a single element from an array of Ints produces an Int";
+ #?pugs todo
ok @a.pick ~~ 1..100, "picking a single element from an array of Ints produces one of them";
+ #?pugs todo
isa_ok @a.pick(1), Int, "picking 1 from an array of Ints produces an Int";
+ #?pugs todo
ok @a.pick(1) ~~ 1..100, "picking 1 from an array of Ints produces one of them";
my @c = @a.pick(2);
isa_ok @c[0], Int, "picking 2 from an array of Ints produces an Int...";
isa_ok @c[1], Int, "... and an Int";
+ #?pugs todo
ok (@c[0] ~~ 1..100) && (@c[1] ~~ 1..100), "picking 2 from an array of Ints produces two of them";
ok @c[0] != @c[1], "picking 2 from an array of Ints produces two distinct results";
+ #?pugs 2 skip "NYI"
is @a.pick("25").elems, 25, ".pick works Str arguments";
is pick("25", @a).elems, 25, "pick works Str arguments";
}
+#?pugs skip "NYI"
{
#?rakudo todo 'error on pick :replace'
dies_ok({ [1,2,3].pick(4, :replace) }, 'error on deprecated :replace');
}
# enums + pick
+#?pugs skip "NYI"
{
is Bool.pick(*).grep(Bool).elems, 2, 'Bool.pick works';
@@ -96,20 +108,23 @@ is (<a b c d>.pick(*).sort).Str, 'a b c d', 'pick(*) returns all the items in th
my %seen;
%seen{$_} = 1 for (1..100).pick(50);
is %seen.keys.elems, 50, 'Range.pick produces uniq elems';
+ #?pugs skip "so"
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';
+ #?pugs skip "so"
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';
+ #?pugs skip "so"
ok (so 1 <= all(%seen.keys) <= 50), '... and all the elements are in range';
}
@@ -121,32 +136,37 @@ is (<a b c d>.pick(*).sort).Str, 'a b c d', 'pick(*) returns all the items in th
my %seen;
%seen{$_} = 1 for (1..1_000_000).pick(50);
is %seen.keys.elems, 50, 'Range.pick produces uniq elems';
+ #?pugs skip "so"
ok (so 1 <= all(%seen.keys) <= 1_000_000), '... and all the elements are in range';
}
{
my %seen;
%seen{$_} = 1 for (1^..1_000_000).pick(50);
is %seen.keys.elems, 50, 'Range.pick produces uniq elems (lower exclusive)';
+ #?pugs skip "so"
ok (so 1 < all(%seen.keys) <= 1_000_000), '... and all the elements are in range';
}
{
my %seen;
%seen{$_} = 1 for (1..^1_000_000).pick(50);
is %seen.keys.elems, 50, 'Range.pick produces uniq elems (upper exclusive)';
+ #?pugs skip "so"
ok (so 1 <= all(%seen.keys) < 1_000_000), '... and all the elements are in range';
}
{
my %seen;
%seen{$_} = 1 for (1^..^1_000_000).pick(50);
is %seen.keys.elems, 50, 'Range.pick produces uniq elems (both exclusive)';
+ #?pugs skip "so"
ok (so 1 < all(%seen.keys) < 1_000_000), '... and all the elements are in range';
}
is (1..^2).pick, 1, 'pick on 1-elem range';
+#?pugs todo
ok ('a'..'z').pick ~~ /\w/, 'Range.pick on non-Int range';
# vim: ft=perl6
View
@@ -10,8 +10,7 @@ Tests for the defined() builtin
=end pod
-
-
+#?pugs skip 'Mu'
ok(!defined(Mu), 'Mu is not defined');
ok(!defined(Int), 'Int is not defined');
ok(!defined(Num), 'Num is not defined');
@@ -34,13 +33,17 @@ ok(defined($foo), 'variable $foo is now defined (as numeric literal 1)');
$foo = "";
ok(defined($foo), 'variable $foo is now defined (as a empty string)');
+#?pugs emit #
$foo = Nil;
+#?pugs skip "Nil"
ok(!defined($foo), 'variable $foo is now undefined again');
$foo = "a";
ok(defined($foo), 'variable $foo is now defined (as string "a")');
+#?pugs emit #
$foo = Mu;
+#?pugs skip 'Mu'
ok(!defined($foo), 'variable $foo is now undefined again');
$foo = "b";
@@ -62,7 +65,9 @@ ok(defined(@bax), 'unassigned variable @bax is defined');
@bax = 3, 4, 5;
ok(defined(@bax), 'unassigned variable @bax is defined');
+#?pugs emit #
@bax = Nil;
+#?pugs skip 'Nil'
ok(defined(@bax), 'variable @bax is defined after assigning Nil');
# try the invocant syntax
@@ -77,13 +82,17 @@ ok(defined(@bax), 'variable @bax is defined after assigning Nil');
$foo = "";
ok($foo.defined, 'variable $foo is now defined (as a empty string)');
+ #?pugs emit #
$foo = Nil;
+ #?pugs skip 'Nil'
ok(!$foo.defined, 'variable $foo is now undefined again');
$foo = "a";
ok($foo.defined, 'variable $foo is now defined (as string "a")');
+ #?pugs emit #
$foo = Mu;
+ #?pugs skip 'Mu'
ok(!$foo.defined, 'variable $foo is now undefined again');
$foo = "b";
@@ -100,6 +109,7 @@ ok(defined(@bax), 'variable @bax is defined after assigning Nil');
# RT #81352
# Ensure that we always get Bools
+#?pugs skip "isa_ok"
{
isa_ok defined(Mu), Bool, 'defined(Mu) returns a Bool';
isa_ok Mu.defined, Bool, 'Mu.defined returns a Bool';

0 comments on commit 30d3be9

Please sign in to comment.