Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 81 lines (65 sloc) 1.563 kb
ebc0a2c [t/spec]
moritz authored
1 use v6;
2 use Test;
2f37cb1 [t/spec] tests for RT #63330 and RT #63332
moritz authored
3 plan 11;
ebc0a2c [t/spec]
moritz authored
4
605c16f [t/spec] fix some of the S12/Roles smartlinks
moritz authored
5 # L<S14/Roles/"Roles may be composed into a class at compile time">
c2f8fec [t] and [t/spec] (two train travels worth of changes):
moritz authored
6
ebc0a2c [t/spec]
moritz authored
7 role rA {
8 method mA1 {
9 'mA1';
10 }
11 method mA2 {
12 'mA2';
13 }
14 };
15
16 role rB {
17 method mB1 {
18 'mB1';
19 }
20 method mB2 {
21 'mB2';
22 }
23 };
24
25 class C1 does rA {
26 method mC1 {
27 'mC1';
28 }
29 };
30
31 my $x = C1.new();
32
33 is $x.mC1, 'mC1', 'Can call method of class with mixed in role';
34 is $x.mA1, 'mA1', 'Call first method from role';
35 is $x.mA2, 'mA2', 'Call second method from role';
36
37 class C2 does rA does rB {
38 method mC2 {
39 'mC2';
40 }
41 }
42
43 my $y = C2.new();
44
45 is $y.mC2, 'mC2', 'Can call method of class with two roles mixed in';
46 is $y.mA1, 'mA1', 'Can call mixed in method (two roles) 1';
47 is $y.mA2, 'mA2', 'Can call mixed in method (two roles) 2';
48 is $y.mB1, 'mB1', 'Can call mixed in method (two roles) 3';
49 is $y.mB2, 'mB2', 'Can call mixed in method (two roles) 4';
50
86dbfdc Fixes from moritz++ to do the test properly
mattw authored
51 {
975b429 [t/spec] indent lines in composition.t to not confuse the fudge script
moritz authored
52 class D1 does rA {
53 method mA1 {
54 'D1.mA1';
55 }
a8fc3f9 test for RT #62200: classes overriding methods from roles
mattw authored
56 }
57
975b429 [t/spec] indent lines in composition.t to not confuse the fudge script
moritz authored
58 my $z = D1.new();
a8fc3f9 test for RT #62200: classes overriding methods from roles
mattw authored
59
975b429 [t/spec] indent lines in composition.t to not confuse the fudge script
moritz authored
60 is $z.mA1, 'D1.mA1', 'Can override method in a role with method in a class';
86dbfdc Fixes from moritz++ to do the test properly
mattw authored
61 }
a8fc3f9 test for RT #62200: classes overriding methods from roles
mattw authored
62
afb3675 [t/spec] Unfudge test for RT#63330.
jnthn authored
63 # diamond composition
2f37cb1 [t/spec] tests for RT #63330 and RT #63332
moritz authored
64 {
65 role DA {
66 method foo { "OH HAI" };
67 }
68 role DB does DA { }
69 role DC does DA { }
70 class DD does DB does DC { };
71 is DD.new.foo, 'OH HAI', 'diamond role composition';
afb3675 [t/spec] Unfudge test for RT#63330.
jnthn authored
72 }
73
74 #?rakudo skip 'RT #63332'
75 {
2f37cb1 [t/spec] tests for RT #63330 and RT #63332
moritz authored
76 class DE is DB is DC { };
77 is DE.new.foo, 'OH HAI', 'same with punning and inheritance';
78 }
79
ebc0a2c [t/spec]
moritz authored
80 # vim: syn=perl6
Something went wrong with that request. Please try again.