Skip to content
Newer
Older
100644 46 lines (34 sloc) 1.3 KB
0df5ccb [t/spec] Basic tests for meta-operators generated from user defined o…
jnthn authored May 20, 2009
1 use v6;
2 use Test;
3
f35b982 @FROGGS RT #122332 test for sub as infix op between []
FROGGS authored Jul 20, 2014
4 plan 11;
0df5ccb [t/spec] Basic tests for meta-operators generated from user defined o…
jnthn authored May 20, 2009
5
6 #L<S06/Operator overloading>
7
8 # Define operator, check it works.
9 sub infix:<wtf>($a, $b) { $a ~ "WTF" ~ $b };
10 is 'OMG' wtf 'BBQ', 'OMGWTFBBQ', 'basic sanity';
11
12 # Assignment meta-op.
13 my $a = 'OMG';
14 $a wtf= 'BBQ';
15 is $a, 'OMGWTFBBQ', 'assignment meta-op';
16
17 # Reduce meta-op.
18 is ([wtf] <OMG BBQ PONIES>), 'OMGWTFBBQWTFPONIES', 'reduce meta-op generated';
19
20 # Reverse meta-op.
21 is 'BBQ' Rwtf 'OMG', 'OMGWTFBBQ', 'reverse meta-op generated';
22
23 # Cross meta-op.
defe8f0 [metaoperators] test that Xwtf is list infixy
lwall authored May 20, 2009
24 is ~('OMG','BBQ' Xwtf 'OMG','BBQ'), 'OMGWTFOMG OMGWTFBBQ BBQWTFOMG BBQWTFBBQ',
0df5ccb [t/spec] Basic tests for meta-operators generated from user defined o…
jnthn authored May 20, 2009
25 'cross meta-op generated';
26
27 # Hyper meta-op (todo: unicode variants, check variants apply correct constraints)
28 is ~(('OMG','BBQ') >>wtf<< ('BBQ','OMG')), 'OMGWTFBBQ BBQWTFOMG', '>>...<< hyper generated';
29 is ~(('OMG','BBQ') <<wtf<< ('BBQ','OMG')), 'OMGWTFBBQ BBQWTFOMG', '<<...<< hyper generated';
30 is ~(('OMG','BBQ') >>wtf>> ('BBQ','OMG')), 'OMGWTFBBQ BBQWTFOMG', '>>...>> hyper generated';
31 is ~(('OMG','BBQ') <<wtf>> ('BBQ','OMG')), 'OMGWTFBBQ BBQWTFOMG', '<<...>> hyper generated';
32
636e4d6 @coke prefer RT #ticket
coke authored Nov 1, 2015
33 # RT #121692
999caf1 @lizmat Add test for RT #121692
lizmat authored Apr 21, 2014
34 {
35 sub foo { $^a ~ $^b };
f35b982 @FROGGS RT #122332 test for sub as infix op between []
FROGGS authored Jul 20, 2014
36 is ([[&foo]] <a b c d e>), 'abcde', "can we use a sub as an reduce op between [[]]";
37 }
38
636e4d6 @coke prefer RT #ticket
coke authored Nov 1, 2015
39 # RT #122332
f35b982 @FROGGS RT #122332 test for sub as infix op between []
FROGGS authored Jul 20, 2014
40 {
41 sub foo ($a, $b) { $a * $b };
42 is (2 [&foo] 3 [&foo] 4), 24, "can we use a sub as an infix op between []";
999caf1 @lizmat Add test for RT #121692
lizmat authored Apr 21, 2014
43 }
44
0df5ccb [t/spec] Basic tests for meta-operators generated from user defined o…
jnthn authored May 20, 2009
45 # vim: ft=perl6
Something went wrong with that request. Please try again.