Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'glr' of https://github.com/perl6/roast into glr
  • Loading branch information
lizmat committed Aug 28, 2015
2 parents 0da7828 + 1846e7f commit a7dafef
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion S03-metaops/hyper.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 304;
plan 318;

=begin pod
Expand Down Expand Up @@ -108,6 +108,16 @@ my @e;
is(~@r, ~@e, "auto dimension upgrade on lhs ASCII notation");
}

{ # both-dwim and non-dwim sanity
my @r = (1,2,3) <<~>> <A B C D E>;
my @e = <1A 2B 3C 1D 2E>;
is(~@r, ~@e, "both dwim short side lengthening on ASCII notation");

throws-like {(1,2,3) >>~<< <A B C D E>}, X::HyperOp::NonDWIM,
left-elems => 3, right-elems => 5,
"both non-dwim dies correctly on ASCII notation";
}

{ # extension
@r = (1,2,3,4) >>~>> <A B C D E>;
@e = <1A 2B 3C 4D>;
Expand Down Expand Up @@ -192,6 +202,49 @@ my @e;
is(~@r, ~@e, "scalar element extension on lhs unicode notation");
};

{ # binary infix with lazy or infinite lists
my @r = (0 xx *) <<+<< (1..9);
my @e = <1 2 3 4 5 6 7 8 9>;
is(~@r, ~@e, "lazy list-level extension on lhs ascii notation");

throws-like {(0 xx *) <<+>> (1..9)}, X::HyperOp::Infinite,
side => <left>,
"lazy list on left side with both dwim dies correctly";
throws-like {(0 xx *) >>+>> (1..9)}, X::HyperOp::Infinite,
side => <left>,
"lazy list on left side with right dwim dies correctly";
throws-like {(0 xx *) >>+<< (1..9)}, X::HyperOp::Infinite,
side => <left>,
"lazy list on left side with both non-dwim dies correctly";

@r = (1..9) >>+>> (0 xx *);
@e = <1 2 3 4 5 6 7 8 9>;
is(~@r, ~@e, "lazy list-level extension on rhs ascii notation");

throws-like {(1..9) <<+>> (0 xx *)}, X::HyperOp::Infinite,
side => <right>,
"lazy list on right side with both dwim dies correctly";
throws-like {(1..9) <<+<< (0 xx *)}, X::HyperOp::Infinite,
side => <right>,
"lazy list on right side with left dwim dies correctly";
throws-like {(1..9) >>+<< (0 xx *)}, X::HyperOp::Infinite,
side => <right>,
"lazy list on right side with both non-dwim dies correctly";

throws-like {(1..Inf) >>+<< (1..Inf)}, X::HyperOp::Infinite,
side => <both>,
"lazy list on both sides with both non-dwim dies correctly";
throws-like {(1..Inf) <<+>> (1..Inf)}, X::HyperOp::Infinite,
side => <both>,
"lazy list on both sides with both dwim dies correctly";
throws-like {(1..Inf) <<+<< (1..Inf)}, X::HyperOp::Infinite,
side => <both>,
"lazy list on both sides with left dwim dies correctly";
throws-like {(1..Inf) >>+>> (1..Inf)}, X::HyperOp::Infinite,
side => <both>,
"lazy list on both sides with right dwim dies correctly";
};

{ # unary postfix with integers
my @r;
@r = (1, 4, 9.sqrt;
Expand Down Expand Up @@ -835,13 +888,15 @@ is ((1, 2) >>[+]<< (100, 200)).join(','), '101,202',
is () »+» (), (), "right-dwim hyper between empty lists doesn't hang";
is () «+» (), (), "both-dwim hyper between empty lists doesn't hang";
# <item> <hyper> <empty list>
#?rakudo 3 skip "broken due to external reasons"
is True «+« (), (), "left-dwim hyper against empty RHS doesn't hang";
is True »+» (), (), "right-dwim hyper against empty RHS doesn't hang";
is True «+» (), (), "both-dwim hyper against empty RHS doesn't hang";
throws-like {True »+« ()}, X::HyperOp::NonDWIM,
left-elems => 1, right-elems => 0,
"non-dwim hyper against empty RHS dies";
# <empty list> <hyper> <item>
#?rakudo 3 skip "broken due to external reasons"
is () «+« True, (), "left-dwim hyper against empty LHS doesn't hang";
is () «+» True, (), "right-dwim hyper against empty LHS doesn't hang";
is () «+» True, (), "both-dwim hyper against empty LHS doesn't hang";
Expand Down

0 comments on commit a7dafef

Please sign in to comment.