Skip to content

Commit 38e207a

Browse files
committed
Test that positional_delegate and associative_delegate are visible through the metamodel.
1 parent 05574c2 commit 38e207a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

t/nqp/73-delegation.t

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
plan(6);
1+
plan(10);
22

33
class Foo {
44
has @!pos_foo;
@@ -30,3 +30,18 @@ ok($foo<1> == 678,"associative access is seperate");
3030
ok($foo<bar> eq 'hello',"assosiative storage takes strings as keys");
3131
ok($foo.get_pos_1 == 456,"positional are stored in the attribute");
3232
ok($foo.get_assoc_1 == 678,"associatives are stored in the attribute");
33+
34+
my $pos_attr;
35+
my $assoc_attr;
36+
for Foo.HOW.attributes(Foo) -> $attr {
37+
if $attr.name eq '@!pos_bar' {
38+
$pos_attr := $attr;
39+
}
40+
elsif $attr.name eq '%!assoc_bar' {
41+
$assoc_attr := $attr;
42+
}
43+
}
44+
ok($pos_attr.positional_delegate == 1,"positional_delegate is set correctly");
45+
ok($pos_attr.associative_delegate == 0,"positional_delegate is not set incorrectly");
46+
ok($assoc_attr.positional_delegate == 0,"associative_delegate is not set incorrectly");
47+
ok($assoc_attr.associative_delegate == 1,"associative_delegate is set correctly");

0 commit comments

Comments
 (0)