Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add tests for autogen of metaops
  • Loading branch information
TimToady committed Oct 30, 2015
1 parent 3185bb0 commit 481a9eb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
4 changes: 3 additions & 1 deletion S03-metaops/cross.t
@@ -1,7 +1,7 @@
use v6;

use Test;
plan 50;
plan 51;

# L<S03/List infix precedence/the cross operator>
ok EVAL('<a b> X <c d>'), 'cross non-meta operator parses';
Expand Down Expand Up @@ -168,4 +168,6 @@ is (1,2 X (<a b> X "x")).flat.join, '1ax1bx2ax2bx',
throws-like '3 X. foo', X::Syntax::CannotMeta, "X. is too fiddly";
throws-like '3 X. "foo"', X::Obsolete, "X. can't do P5 concat";

is-deeply &infix:<X+>((1,2,3),(4,5,6)), (5, 6, 7, 6, 7, 8, 7, 8, 9), "Meta X can autogen";

# vim: ft=perl6
7 changes: 6 additions & 1 deletion S03-metaops/hyper.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 386;
plan 390;

=begin pod
Expand Down Expand Up @@ -1017,4 +1017,9 @@ throws-like '3 «.» foo', X::Obsolete, "«.» can't be hypered";
'hyper op works with (finite) range on non-magical side (3)';
}

is-deeply &infix:<»+«>((1,2,3),(4,5,6)), (5, 7, 9), "Hyper >><< can autogen";
is-deeply &infix:<»+»>((1,2,3),1), (2, 3, 4), "Hyper >>>> can autogen";
is-deeply &infix:<«+«>(1,(4,5,6)), (5, 6, 7), "Hyper <<<< can autogen";
is-deeply &infix:<«+»>((1,2),(4,5,6)), (5, 7, 7), "Hyper <<>> can autogen";

# vim: ft=perl6
6 changes: 5 additions & 1 deletion S03-metaops/not.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 41;
plan 44;

=begin pod
Expand Down Expand Up @@ -65,4 +65,8 @@ nok False !^^ True, '!^^ is legal and works (2)';
throws-like '3 !. foo', X::Syntax::CannotMeta, "!. is too fiddly";
throws-like '3 !. "foo"', X::Obsolete, "!. can't do P5 concat";

is &infix:<!===>(1,2), True, "Meta not can autogen (!===)";
is &infix:<!%%>(3,2), True, "Meta not can autogen (!%%)";
is &infix:<![!%%]>(3,2), False, "Meta not can autogen (![!%%])";

# vim: ft=perl6
5 changes: 4 additions & 1 deletion S03-metaops/reduce.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 372;
plan 374;

=begin pod
Expand Down Expand Up @@ -395,4 +395,7 @@ ok ([+]) == 0, 'argumentless [+] parses';
}


is &prefix:<[**]>(2,3,4), 2417851639229258349412352, "Reduce ** can autogen";
is &prefix:<[R**]>(2,3,4), 262144, "Reduce R** can autogen";

# vim: ft=perl6
6 changes: 5 additions & 1 deletion S03-metaops/reverse.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 42;
plan 44;

=begin pod
Expand Down Expand Up @@ -98,4 +98,8 @@ throws-like '("a" R~ "b") = 1', X::Assignment::RO, 'Cannot assign to return valu

throws-like '3 R. foo', X::Syntax::CannotMeta, "R. is too fiddly";
throws-like '3 R. "foo"', X::Obsolete, "R. can't do P5 concat";

is &infix:<R/>(1,2), 2, "Meta reverse R/ can autogen";
is &infix:<RR/>(1,2), 0.5, "Meta reverse RR/ can autogen";

# vim: ft=perl6
5 changes: 4 additions & 1 deletion S03-metaops/zip.t
@@ -1,7 +1,7 @@
use v6;

use Test;
plan 49;
plan 51;

ok EVAL('<a b> Z <c d>'), 'zip non-meta operator parses';

Expand Down Expand Up @@ -119,4 +119,7 @@ is (1, 2 Z, 3, 4).flat.join('|'), '1|3|2|4', 'Z, flattens in list context';
throws-like '3 Z. foo', X::Syntax::CannotMeta, "Z. is too fiddly";
throws-like '3 Z. "foo"', X::Obsolete, "Z. can't do P5 concat";

is-deeply &infix:<Z+>((1,2,3),(4,5,6)), (5, 7, 9), "Meta zip can autogen";
is-deeply &infix:<Z+>((1,2,3),(1,2,3),(1,2,3)), (3, 6, 9), "Meta zip can autogen (3-ary)";

# vim: ft=perl6

0 comments on commit 481a9eb

Please sign in to comment.