Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 51 lines (41 sloc) 0.902 kB
ad116db [t] move operators/recursive_definition.t to spec/, and add a simpler…
moritz authored
1 use v6;
2 use Test;
3
160bc8b @moritz test for overriding invoke with postcircumfix:<( )>
moritz authored
4 plan 4;
ad116db [t] move operators/recursive_definition.t to spec/, and add a simpler…
moritz authored
5
6 #L<S06/Operator overloading>
7
8 {
001e798 @moritz &eval does not catch exceptions.
moritz authored
9 sub postfix:<§> ($x) {
10 $x * 2;
11 };
12 is 3§, 6, 'Can define postfix operator';
ad116db [t] move operators/recursive_definition.t to spec/, and add a simpler…
moritz authored
13 }
14
15 {
001e798 @moritz &eval does not catch exceptions.
moritz authored
16 sub postfix:<!>($arg) {
17 if ($arg == 0) { 1;}
18 else { ($arg-1)! * $arg;}
19 };
20 is 5!, 120, 'Can define recursive postfix operator';
ad116db [t] move operators/recursive_definition.t to spec/, and add a simpler…
moritz authored
21 }
22
abc9cbd @coke pugs fudge
coke authored
23 #?pugs todo
4e0660e [S13-overloading/operators.t] added test about postcircumfix:<{ }>
masak authored
24 {
25 class A does Associative {
26 method postcircumfix:<{ }>(*@ix) {
27 return @ix
28 }
29 };
30
31 is A.new<foo bar>, <foo bar>, 'defining postcircumfix:<{ }> works';
32 }
ad116db [t] move operators/recursive_definition.t to spec/, and add a simpler…
moritz authored
33
160bc8b @moritz test for overriding invoke with postcircumfix:<( )>
moritz authored
34 # overloaded invoke
35 # RT #76330
36 # (even though the ticket title claims it, the actual problem was not related
37 # to monkey typing/augmenting at all)
38
abc9cbd @coke pugs fudge
coke authored
39 #?pugs skip 'Cannot cast from VObject'
160bc8b @moritz test for overriding invoke with postcircumfix:<( )>
moritz authored
40 {
41 class B {
42 has $.x;
43 method postcircumfix:<( )>($y) {
44 $.x ~ $y;
45 }
46 }
47 is B.new(x => 'a').('b'), 'ab', 'can overload invoke';
48 }
49
ad116db [t] move operators/recursive_definition.t to spec/, and add a simpler…
moritz authored
50 # vim: ft=perl6
Something went wrong with that request. Please try again.