Skip to content

Commit

Permalink
benign prep for ~~ going chained -> structural
Browse files Browse the repository at this point in the history
Just the addition of parentheses that will be required in the future.
  • Loading branch information
TimToady committed Jul 24, 2015
1 parent 49828cd commit ab605d9
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 126 deletions.
34 changes: 17 additions & 17 deletions S02-types/range.t
Expand Up @@ -52,7 +52,7 @@ is ('a'..'a'), [< a >], 'got the right array';
ok(($r).ACCEPTS($r), 'accepts self');
ok(($r).ACCEPTS(1..5), 'accepts same');
ok($r ~~ $r, 'accepts self');
ok($r ~~ 1..5, 'accepts same');
ok($r ~~ (1..5), 'accepts same');
# TODO check how to avoid "eager is", test passes but why?
is($r, $r, "equals to self");
my $s = 1..5;
Expand All @@ -62,12 +62,12 @@ is ('a'..'a'), [< a >], 'got the right array';

# Range in comparisons
ok((1..5).ACCEPTS(3), 'int in range');
ok(3 ~~ 1..5, 'int in range');
ok(3 !~~ 6..8, 'int not in range');
ok(3 ~~ (1..5), 'int in range');
ok(3 !~~ (6..8), 'int not in range');

ok(('a'..'z').ACCEPTS('x'), 'str in range');
ok('x' ~~ 'a'..'z', 'str in range');
ok('x' !~~ 'a'..'c', 'str not in range');
ok('x' ~~ ('a'..'z'), 'str in range');
ok('x' !~~ ('a'..'c'), 'str not in range');
ok(('aa'..'zz').ACCEPTS('ax'), 'str in range');
ok(('a'..'zz').ACCEPTS('ax'), 'str in range');

Expand Down Expand Up @@ -171,15 +171,15 @@ is(+Range, 0, 'type numification');
is ~@b.grep(Int).elems, 100, "pick(*, 1..100) returns Ints";

isa-ok (1..100).pick, Int, "picking a single element from an range of Ints produces an Int";
ok (1..100).pick ~~ 1..100, "picking a single element from an range of Ints produces one of them";
ok (1..100).pick ~~ (1..100), "picking a single element from an range of Ints produces one of them";

isa-ok (1..100).pick(1), List, "picking 1 from an range of Ints produces a List";
ok (1..100).pick(1)[0] ~~ 1..100, "picking 1 from an range of Ints produces one of them";
ok (1..100).pick(1)[0] ~~ (1..100), "picking 1 from an range of Ints produces one of them";

my @c = (1..100).pick(2);
isa-ok @c[0], Int, "picking 2 from an range of Ints produces an Int...";
isa-ok @c[1], Int, "... and an Int";
ok (@c[0] ~~ 1..100) && (@c[1] ~~ 1..100), "picking 2 from an range of Ints produces two of them";
ok (@c[0] ~~ (1..100)) && (@c[1] ~~ (1..100)), "picking 2 from an range of Ints produces two of them";
ok @c[0] != @c[1], "picking 2 from an range of Ints produces two distinct results";

is (1..100).pick("25").elems, 25, ".pick works Str arguments";
Expand All @@ -198,15 +198,15 @@ is(+Range, 0, 'type numification');
is ~@b.grep(Str).elems, 24, "pick(*, 'b' .. 'y') returns Strs";

isa-ok ('b' .. 'y').pick, Str, "picking a single element from an range of Strs produces an Str";
ok ('b' .. 'y').pick ~~ 'b' .. 'y', "picking a single element from an range of Strs produces one of them";
ok ('b' .. 'y').pick ~~ ('b' .. 'y'), "picking a single element from an range of Strs produces one of them";

isa-ok ('b' .. 'y').pick(1), List, "picking 1 from an range of Strs produces a List";
ok ('b' .. 'y').pick(1)[0] ~~ 'b' .. 'y', "picking 1 from an range of Strs produces one of them";
ok ('b' .. 'y').pick(1)[0] ~~ ('b' .. 'y'), "picking 1 from an range of Strs produces one of them";

my @c = ('b' .. 'y').pick(2);
isa-ok @c[0], Str, "picking 2 from an range of Strs produces an Str...";
isa-ok @c[1], Str, "... and an Str";
ok (@c[0] ~~ 'b' .. 'y') && (@c[1] ~~ 'b' .. 'y'), "picking 2 from an range of Strs produces two of them";
ok (@c[0] ~~ ('b' .. 'y')) && (@c[1] ~~ ('b' .. 'y')), "picking 2 from an range of Strs produces two of them";
ok @c[0] ne @c[1], "picking 2 from an range of Strs produces two distinct results";

is ('b' .. 'y').pick("10").elems, 10, ".pick works Str arguments";
Expand All @@ -225,15 +225,15 @@ is(+Range, 0, 'type numification');
is ~@b.grep(Int).elems, 100, "roll(100, 1..100) returns Ints";

isa-ok (1..100).roll, Int, "rolling a single element from an range of Ints produces an Int";
ok (1..100).roll ~~ 1..100, "rolling a single element from an range of Ints produces one of them";
ok (1..100).roll ~~ (1..100), "rolling a single element from an range of Ints produces one of them";

isa-ok (1..100).roll(1), List, "rolling 1 from an range of Ints produces a List";
ok (1..100).roll(1)[0] ~~ 1..100, "rolling 1 from an range of Ints produces one of them";
ok (1..100).roll(1)[0] ~~ (1..100), "rolling 1 from an range of Ints produces one of them";

my @c = (1..100).roll(2);
isa-ok @c[0], Int, "rolling 2 from an range of Ints produces an Int...";
isa-ok @c[1], Int, "... and an Int";
ok (@c[0] ~~ 1..100) && (@c[1] ~~ 1..100), "rolling 2 from an range of Ints produces two of them";
ok (@c[0] ~~ (1..100)) && (@c[1] ~~ (1..100)), "rolling 2 from an range of Ints produces two of them";

is (1..100).roll("25").elems, 25, ".roll works Str arguments";
is roll("25", 1..100).elems, 25, "roll works Str arguments";
Expand All @@ -251,15 +251,15 @@ is(+Range, 0, 'type numification');
is ~@b.grep(Str).elems, 100, "roll(100, 'b' .. 'y') returns Strs";

isa-ok ('b' .. 'y').roll, Str, "rolling a single element from an range of Strs produces an Str";
ok ('b' .. 'y').roll ~~ 'b' .. 'y', "rolling a single element from an range of Strs produces one of them";
ok ('b' .. 'y').roll ~~ ('b' .. 'y'), "rolling a single element from an range of Strs produces one of them";

isa-ok ('b' .. 'y').roll(1), List, "rolling 1 from an range of Strs produces a List";
ok ('b' .. 'y').roll(1)[0] ~~ 'b' .. 'y', "rolling 1 from an range of Strs produces one of them";
ok ('b' .. 'y').roll(1)[0] ~~ ('b' .. 'y'), "rolling 1 from an range of Strs produces one of them";

my @c = ('b' .. 'y').roll(2);
isa-ok @c[0], Str, "rolling 2 from an range of Strs produces an Str...";
isa-ok @c[1], Str, "... and an Str";
ok (@c[0] ~~ 'b' .. 'y') && (@c[1] ~~ 'b' .. 'y'), "rolling 2 from an range of Strs produces two of them";
ok (@c[0] ~~ ('b' .. 'y')) && (@c[1] ~~ ('b' .. 'y')), "rolling 2 from an range of Strs produces two of them";

is ('b' .. 'y').roll("10").elems, 10, ".roll works Str arguments";
is roll("10", 'b' .. 'y').elems, 10, "roll works Str arguments";
Expand Down
158 changes: 79 additions & 79 deletions S03-operators/range-basic.t
Expand Up @@ -122,94 +122,94 @@ plan 140;
throws-like '^10 .. *', X::Range::InvalidArg ;
}

ok 3 ~~ 1..5, '3 ~~ 1..5';
ok 2.5 ~~ 1..5, '2.5 ~~ 1..5';
ok 2.5e0 ~~ 1..5, '2.5e0 ~~ 1..5';
ok 1 ~~ 1..5, '1 ~~ 1..5';
ok 1.0 ~~ 1..5, '1.0 ~~ 1..5';
ok 1.0e0 ~~ 1..5, '1.0e0 ~~ 1..5';
ok 5 ~~ 1..5, '5 ~~ 1..5';
ok 5.0 ~~ 1..5, '5.0 ~~ 1..5';
ok 5.0e0 ~~ 1..5, '5.0e0 ~~ 1..5';
nok 0 ~~ 1..5, 'not 0 ~~ 1..5';
nok 0.999 ~~ 1..5, 'not 0.999 ~~ 1..5';
nok 0.999e0 ~~ 1..5, 'not 0.999e0 ~~ 1..5';
nok 6 ~~ 1..5, 'not 6 ~~ 1..5';
nok 5.001 ~~ 1..5, 'not 5.001 ~~ 1..5';
nok 5.001e0 ~~ 1..5, 'not 5.001e0 ~~ 1..5';

ok 3 ~~ 1^..5, '3 ~~ 1^..5';
ok 2.5 ~~ 1^..5, '2.5 ~~ 1^..5';
ok 2.5e0 ~~ 1^..5, '2.5e0 ~~ 1^..5';
nok 1 ~~ 1^..5, 'not 1 ~~ 1^..5';
nok 1.0 ~~ 1^..5, 'not 1.0 ~~ 1^..5';
nok 1.0e0 ~~ 1^..5, 'not 1.0e0 ~~ 1^..5';
ok 5 ~~ 1^..5, '5 ~~ 1^..5';
ok 5.0 ~~ 1^..5, '5.0 ~~ 1^..5';
ok 5.0e0 ~~ 1^..5, '5.0e0 ~~ 1^..5';
nok 0 ~~ 1^..5, 'not 0 ~~ 1^..5';
nok 0.999 ~~ 1^..5, 'not 0.999 ~~ 1^..5';
nok 0.999e0 ~~ 1^..5, 'not 0.999e0 ~~ 1^..5';
nok 6 ~~ 1^..5, 'not 6 ~~ 1^..5';
nok 5.001 ~~ 1^..5, 'not 5.001 ~~ 1^..5';
nok 5.001e0 ~~ 1^..5, 'not 5.001e0 ~~ 1^..5';

ok 3 ~~ 1..^5, '3 ~~ 1..^5';
ok 2.5 ~~ 1..^5, '2.5 ~~ 1..^5';
ok 2.5e0 ~~ 1..^5, '2.5e0 ~~ 1..^5';
ok 1 ~~ 1..^5, '1 ~~ 1..^5';
ok 1.0 ~~ 1..^5, '1.0 ~~ 1..^5';
ok 1.0e0 ~~ 1..^5, '1.0e0 ~~ 1..^5';
nok 5 ~~ 1..^5, 'not 5 ~~ 1..^5';
nok 5.0 ~~ 1..^5, 'not 5.0 ~~ 1..^5';
nok 5.0e0 ~~ 1..^5, 'not 5.0e0 ~~ 1..^5';
nok 0 ~~ 1..^5, 'not 0 ~~ 1..^5';
nok 0.999 ~~ 1..^5, 'not 0.999 ~~ 1..^5';
nok 0.999e0 ~~ 1..^5, 'not 0.999e0 ~~ 1..^5';
nok 6 ~~ 1..^5, 'not 6 ~~ 1..^5';
nok 5.001 ~~ 1..^5, 'not 5.001 ~~ 1..^5';
nok 5.001e0 ~~ 1..^5, 'not 5.001e0 ~~ 1..^5';

ok 3 ~~ 1^..^5, '3 ~~ 1^..^5';
ok 2.5 ~~ 1^..^5, '2.5 ~~ 1^..^5';
ok 2.5e0 ~~ 1^..^5, '2.5e0 ~~ 1^..^5';
nok 1 ~~ 1^..^5, 'not 1 ~~ 1^..^5';
nok 1.0 ~~ 1^..^5, 'not 1.0 ~~ 1^..^5';
nok 1.0e0 ~~ 1^..^5, 'not 1.0e0 ~~ 1^..^5';
nok 5 ~~ 1^..^5, 'not 5 ~~ 1^..^5';
nok 5.0 ~~ 1^..^5, 'not 5.0 ~~ 1^..^5';
nok 5.0e0 ~~ 1^..^5, 'not 5.0e0 ~~ 1^..^5';
nok 0 ~~ 1^..^5, 'not 0 ~~ 1^..^5';
nok 0.999 ~~ 1^..^5, 'not 0.999 ~~ 1^..^5';
nok 0.999e0 ~~ 1^..^5, 'not 0.999e0 ~~ 1^..^5';
nok 6 ~~ 1^..^5, 'not 6 ~~ 1^..^5';
nok 5.001 ~~ 1^..^5, 'not 5.001 ~~ 1^..^5';
nok 5.001e0 ~~ 1^..^5, 'not 5.001e0 ~~ 1^..^5';
ok 3 ~~ (1..5), '3 ~~ 1..5';
ok 2.5 ~~ (1..5), '2.5 ~~ 1..5';
ok 2.5e0 ~~ (1..5), '2.5e0 ~~ 1..5';
ok 1 ~~ (1..5), '1 ~~ 1..5';
ok 1.0 ~~ (1..5), '1.0 ~~ 1..5';
ok 1.0e0 ~~ (1..5), '1.0e0 ~~ 1..5';
ok 5 ~~ (1..5), '5 ~~ 1..5';
ok 5.0 ~~ (1..5), '5.0 ~~ 1..5';
ok 5.0e0 ~~ (1..5), '5.0e0 ~~ 1..5';
nok 0 ~~ (1..5), 'not 0 ~~ 1..5';
nok 0.999 ~~ (1..5), 'not 0.999 ~~ 1..5';
nok 0.999e0 ~~ (1..5), 'not 0.999e0 ~~ 1..5';
nok 6 ~~ (1..5), 'not 6 ~~ 1..5';
nok 5.001 ~~ (1..5), 'not 5.001 ~~ 1..5';
nok 5.001e0 ~~ (1..5), 'not 5.001e0 ~~ 1..5';

ok 3 ~~ (1^..5), '3 ~~ 1^..5';
ok 2.5 ~~ (1^..5), '2.5 ~~ 1^..5';
ok 2.5e0 ~~ (1^..5), '2.5e0 ~~ 1^..5';
nok 1 ~~ (1^..5), 'not 1 ~~ 1^..5';
nok 1.0 ~~ (1^..5), 'not 1.0 ~~ 1^..5';
nok 1.0e0 ~~ (1^..5), 'not 1.0e0 ~~ 1^..5';
ok 5 ~~ (1^..5), '5 ~~ 1^..5';
ok 5.0 ~~ (1^..5), '5.0 ~~ 1^..5';
ok 5.0e0 ~~ (1^..5), '5.0e0 ~~ 1^..5';
nok 0 ~~ (1^..5), 'not 0 ~~ 1^..5';
nok 0.999 ~~ (1^..5), 'not 0.999 ~~ 1^..5';
nok 0.999e0 ~~ (1^..5), 'not 0.999e0 ~~ 1^..5';
nok 6 ~~ (1^..5), 'not 6 ~~ 1^..5';
nok 5.001 ~~ (1^..5), 'not 5.001 ~~ 1^..5';
nok 5.001e0 ~~ (1^..5), 'not 5.001e0 ~~ 1^..5';

ok 3 ~~ (1..^5), '3 ~~ 1..^5';
ok 2.5 ~~ (1..^5), '2.5 ~~ 1..^5';
ok 2.5e0 ~~ (1..^5), '2.5e0 ~~ 1..^5';
ok 1 ~~ (1..^5), '1 ~~ 1..^5';
ok 1.0 ~~ (1..^5), '1.0 ~~ 1..^5';
ok 1.0e0 ~~ (1..^5), '1.0e0 ~~ 1..^5';
nok 5 ~~ (1..^5), 'not 5 ~~ 1..^5';
nok 5.0 ~~ (1..^5), 'not 5.0 ~~ 1..^5';
nok 5.0e0 ~~ (1..^5), 'not 5.0e0 ~~ 1..^5';
nok 0 ~~ (1..^5), 'not 0 ~~ 1..^5';
nok 0.999 ~~ (1..^5), 'not 0.999 ~~ 1..^5';
nok 0.999e0 ~~ (1..^5), 'not 0.999e0 ~~ 1..^5';
nok 6 ~~ (1..^5), 'not 6 ~~ 1..^5';
nok 5.001 ~~ (1..^5), 'not 5.001 ~~ 1..^5';
nok 5.001e0 ~~ (1..^5), 'not 5.001e0 ~~ 1..^5';

ok 3 ~~ (1^..^5), '3 ~~ 1^..^5';
ok 2.5 ~~ (1^..^5), '2.5 ~~ 1^..^5';
ok 2.5e0 ~~ (1^..^5), '2.5e0 ~~ 1^..^5';
nok 1 ~~ (1^..^5), 'not 1 ~~ 1^..^5';
nok 1.0 ~~ (1^..^5), 'not 1.0 ~~ 1^..^5';
nok 1.0e0 ~~ (1^..^5), 'not 1.0e0 ~~ 1^..^5';
nok 5 ~~ (1^..^5), 'not 5 ~~ 1^..^5';
nok 5.0 ~~ (1^..^5), 'not 5.0 ~~ 1^..^5';
nok 5.0e0 ~~ (1^..^5), 'not 5.0e0 ~~ 1^..^5';
nok 0 ~~ (1^..^5), 'not 0 ~~ 1^..^5';
nok 0.999 ~~ (1^..^5), 'not 0.999 ~~ 1^..^5';
nok 0.999e0 ~~ (1^..^5), 'not 0.999e0 ~~ 1^..^5';
nok 6 ~~ (1^..^5), 'not 6 ~~ 1^..^5';
nok 5.001 ~~ (1^..^5), 'not 5.001 ~~ 1^..^5';
nok 5.001e0 ~~ (1^..^5), 'not 5.001e0 ~~ 1^..^5';

# Tests which check to see if Range is properly doing numeric
# comparisons for numbers.

ok 6 ~~ 5..21, '6 ~~ 5..21';
ok 21 ~~ 3..50, '21 ~~ 3..50';
nok 3 ~~ 11..50, 'not 3 ~~ 11..50';
nok 21 ~~ 1..5, 'not 21 ~~ 1..5';
ok 6 ~~ (5..21), '6 ~~ 5..21';
ok 21 ~~ (3..50), '21 ~~ 3..50';
nok 3 ~~ (11..50), 'not 3 ~~ 11..50';
nok 21 ~~ (1..5), 'not 21 ~~ 1..5';

ok 'c' ~~ 'b'..'g', "'c' ~~ 'b'..'g'";
ok 'b' ~~ 'b'..'g', "'b' ~~ 'b'..'g'";
ok 'g' ~~ 'b'..'g', "'g' ~~ 'b'..'g'";
nok 'a' ~~ 'b'..'g', "not 'a' ~~ 'b'..'g'";
nok 'h' ~~ 'b'..'g', "not 'h' ~~ 'b'..'g'";
nok 0 ~~ 'a'..'g', "not 0 ~~ 'a'..'g'";
ok 'c' ~~ ('b'..'g'), "'c' ~~ 'b'..'g'";
ok 'b' ~~ ('b'..'g'), "'b' ~~ 'b'..'g'";
ok 'g' ~~ ('b'..'g'), "'g' ~~ 'b'..'g'";
nok 'a' ~~ ('b'..'g'), "not 'a' ~~ 'b'..'g'";
nok 'h' ~~ ('b'..'g'), "not 'h' ~~ 'b'..'g'";
nok 0 ~~ ('a'..'g'), "not 0 ~~ 'a'..'g'";

ok 'd' ~~ 'c'..*, "'d' ~~ 'c'..*";
nok 'b' ~~ 'c'..*, "not 'b' ~~ 'c'..*";
ok 'b' ~~ *..'c', "'b' ~~ *..'c'";
nok 'd' ~~ *..'c', "not 'd' ~~ *..'c'";
ok 'd' ~~ ('c'..*), "'d' ~~ 'c'..*";
nok 'b' ~~ ('c'..*), "not 'b' ~~ 'c'..*";
ok 'b' ~~ (*..'c'), "'b' ~~ *..'c'";
nok 'd' ~~ (*..'c'), "not 'd' ~~ *..'c'";

# RT #75526: [BUG] Some non-alphanumeric ranges don't work
{
ok ' ' ~~ ' '..' ', "' ' ~~ ' '..' '";
ok ' ' ~~ ' '..'A', "' ' ~~ ' '..'A'";
ok ' ' ~~ (' '..' '), "' ' ~~ ' '..' '";
ok ' ' ~~ (' '..'A'), "' ' ~~ ' '..'A'";
}

# vim: ft=perl6
2 changes: 1 addition & 1 deletion S03-operators/range.t
Expand Up @@ -61,7 +61,7 @@ is ['b'^..^'a'], [], "double-exclusive string auto-rev range (^..^) can produce
is ['a' ^..^ 'a'], [], "double-exclusive range (x ^..^ x) where x is a char";
is ('a'..'z').list.join(' '), 'a b c d e f g h i j k l m n o p q r s t u v w x y z', '"a".."z"';

is 1.5 ~~ 1^..^2, Bool::True, "lazy evaluation of the range operator";
is 1.5 ~~ (1 ^..^ 2), Bool::True, "lazy evaluation of the range operator";

# Test the unary ^ operator
is ~(^5), "0 1 2 3 4", "unary ^num produces the range 0..^num";
Expand Down
5 changes: 1 addition & 4 deletions S03-operators/reduce-le1arg.t
@@ -1,7 +1,7 @@
use v6;

use Test;
plan 54;
plan 52;

# smartlink to top and bottom of long table
# L<S03/Reduction operators/"Builtin reduce operators return the following identity values">
Expand Down Expand Up @@ -39,9 +39,6 @@ is ([>] ()), Bool::True, "[>] () eq True";
is ([>=] ()), Bool::True, "[>=] () eq True";
is ([before] ()), Bool::True, "[before] () eq True";
is ([after] ()), Bool::True, "[after] () eq True";
is ([~~] ()), Bool::True, "[~~] () eq True";
#?rakudo skip 'expected Any but got Mu instead RT #124552'
is ([!~~] ()), Bool::True, "[!~~] () eq True";
is ([eq] ()), Bool::True, "[eq] () eq True)";
is ([ne] ()), Bool::True, "[ne] () eq True)";
is ([!eq] ()), Bool::True, "[!eq] () eq True";
Expand Down
2 changes: 1 addition & 1 deletion S03-smartmatch/array-array.t
Expand Up @@ -64,7 +64,7 @@ plan 36;
ok ((1, 2, 3) ~~ @m), 'smartmatch List ~~ Array with dwim';

ok (1 ~~ *,1,*), 'smartmatch with Array RHS co-erces LHS to list';
ok (1..10 ~~ *,5,*), 'smartmatch with Array RHS co-erces LHS to list';
ok ((1..10) ~~ *,5,*), 'smartmatch with Array RHS co-erces LHS to list';
}

# vim: ft=perl6
8 changes: 4 additions & 4 deletions S03-smartmatch/disorganized.t
Expand Up @@ -30,10 +30,10 @@ sub eval_elsewhere($code){ EVAL($code) }
#L<S03/"Smart matching"/in range>
{
# more range tests in t/spec/S03-operators/range.t
ok((5 ~~ 1 .. 10), "5 is in 1 .. 10");
ok(!(10 ~~ 1 .. 5), "10 is not in 1 .. 5");
ok(!(1 ~~ 5 .. 10), "1 is not i n 5 .. 10");
ok(!(5 ~~ 5 ^..^ 10), "5 is not in 5 .. 10, exclusive");
ok((5 ~~ (1 .. 10)), "5 is in 1 .. 10");
ok(!(10 ~~ (1 .. 5)), "10 is not in 1 .. 5");
ok(!(1 ~~ (5 .. 10)), "1 is not i n 5 .. 10");
ok(!(5 ~~ (5 ^..^ 10)), "5 is not in 5 .. 10, exclusive");
};

# TODO:
Expand Down
28 changes: 14 additions & 14 deletions S03-smartmatch/range-range.t
Expand Up @@ -10,20 +10,20 @@ plan 14;
# (though this is only true to a first approximation, as
# those .min and .max values might be excluded)

ok (2..3 ~~ 1..4), 'proper inclusion +';
ok !(1..4 ~~ 2..3), 'proper inclusion -';
ok (2..4 ~~ 1..4), 'inclusive vs inclusive right end';
ok (2..^4 ~~ 1..4), 'exclusive vs inclusive right end';
ok !(2..4 ~~ 1..^4), 'inclusive vs exclusive right end';
ok (2..^4 ~~ 1..^4), 'exclusive vs exclusive right end';
ok (2..3 ~~ 2..4), 'inclusive vs inclusive left end';
ok (2^..3 ~~ 2..4), 'exclusive vs inclusive left end';
ok !(2..3 ~~ 2^..4), 'inclusive vs exclusive left end';
ok (2^..3 ~~ 2^..4), 'exclusive vs exclusive left end';
ok (2..3 ~~ 2..3), 'inclusive vs inclusive both ends';
ok (2^..^3 ~~ 2..3), 'exclusive vs inclusive both ends';
ok !(2..3 ~~ 2^..^3), 'inclusive vs exclusive both ends';
ok (2^..^3 ~~ 2^..^3), 'exclusive vs exclusive both ends';
ok ((2..3) ~~ (1..4)), 'proper inclusion +';
ok !((1..4) ~~ (2..3)), 'proper inclusion -';
ok ((2..4) ~~ (1..4)), 'inclusive vs inclusive right end';
ok ((2..^4) ~~ (1..4)), 'exclusive vs inclusive right end';
ok !((2..4) ~~ (1..^4)), 'inclusive vs exclusive right end';
ok ((2..^4) ~~ (1..^4)), 'exclusive vs exclusive right end';
ok ((2..3) ~~ (2..4)), 'inclusive vs inclusive left end';
ok ((2^..3) ~~ (2..4)), 'exclusive vs inclusive left end';
ok !((2..3) ~~ (2^..4)), 'inclusive vs exclusive left end';
ok ((2^..3) ~~ (2^..4)), 'exclusive vs exclusive left end';
ok ((2..3) ~~ (2..3)), 'inclusive vs inclusive both ends';
ok ((2^..^3) ~~ (2..3)), 'exclusive vs inclusive both ends';
ok !((2..3) ~~ (2^..^3)), 'inclusive vs exclusive both ends';
ok ((2^..^3) ~~ (2^..^3)), 'exclusive vs exclusive both ends';
}

# vim: ft=perl6
6 changes: 3 additions & 3 deletions S32-list/pick.t
Expand Up @@ -62,15 +62,15 @@ 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";
ok @a.pick ~~ 1..100, "picking a single element from an array of Ints produces one of them";
ok @a.pick ~~ (1..100), "picking a single element from an array of Ints produces one of them";

isa-ok @a.pick(1), List, "picking 1 from an array of Ints produces a List";
ok @a.pick(1)[0] ~~ 1..100, "picking 1 from an array of Ints produces one of them";
ok @a.pick(1)[0] ~~ (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";
ok (@c[0] ~~ 1..100) && (@c[1] ~~ 1..100), "picking 2 from an array of Ints produces two of them";
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";

is @a.pick("25").elems, 25, ".pick works Str arguments";
Expand Down

0 comments on commit ab605d9

Please sign in to comment.