Skip to content

Commit 5a0c386

Browse files
committed
Some tests on roles + handles.
Covers RT #64766, which was filed long ago and had somewhat bogus expectations. We should at least test how things are meant to work, though.
1 parent 08952f6 commit 5a0c386

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

S14-roles/composition.t

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use v6;
22
use Test;
3-
plan 26;
3+
plan 31;
44

55
# L<S14/Roles/"Roles may be composed into a class at compile time">
66

@@ -131,4 +131,36 @@ ok rB !~~ RT64002, 'role not matched by second role it does';
131131
'can use a sub from the setting in a method composed from a role';
132132
}
133133

134+
# RT #64766
135+
{
136+
my class A {
137+
method foo { "OH HAI" }
138+
method aie { "AIE!" }
139+
}
140+
141+
{
142+
my role B { has A $.bar handles 'aie' }
143+
my class C does B { }
144+
is C.new.aie, 'AIE!', 'literal handles from role is composed (1)';
145+
throws-like { C.new.foo }, X::Method::NotFound,
146+
'literal handles from role is composed (2)';
147+
}
148+
149+
{
150+
my role B { has A $.bar handles * }
151+
my class C does B { }
152+
is C.new.foo, 'OH HAI', 'wildcard handles from role is composed (1)';
153+
is C.new.aie, 'AIE!', 'wildcard handles from role is composed (2)';
154+
}
155+
156+
eval-dies-ok q:to/END/, 'attributes conflict in role composition';
157+
my role B {
158+
has A $.bar handles "aie"
159+
}
160+
my class C does B {
161+
has A $.bar handles "foo"
162+
}
163+
END
164+
}
165+
134166
# vim: syn=perl6

0 commit comments

Comments
 (0)