Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test that positional_delegate and associative_delegate are visible th…
…rough the metamodel.
  • Loading branch information
pmurias committed Jul 21, 2013
1 parent 05574c2 commit 38e207a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion t/nqp/73-delegation.t
@@ -1,4 +1,4 @@
plan(6);
plan(10);

class Foo {
has @!pos_foo;
Expand Down Expand Up @@ -30,3 +30,18 @@ ok($foo<1> == 678,"associative access is seperate");
ok($foo<bar> eq 'hello',"assosiative storage takes strings as keys");
ok($foo.get_pos_1 == 456,"positional are stored in the attribute");
ok($foo.get_assoc_1 == 678,"associatives are stored in the attribute");

my $pos_attr;
my $assoc_attr;
for Foo.HOW.attributes(Foo) -> $attr {
if $attr.name eq '@!pos_bar' {
$pos_attr := $attr;
}
elsif $attr.name eq '%!assoc_bar' {
$assoc_attr := $attr;
}
}
ok($pos_attr.positional_delegate == 1,"positional_delegate is set correctly");
ok($pos_attr.associative_delegate == 0,"positional_delegate is not set incorrectly");
ok($assoc_attr.positional_delegate == 0,"associative_delegate is not set incorrectly");
ok($assoc_attr.associative_delegate == 1,"associative_delegate is set correctly");

0 comments on commit 38e207a

Please sign in to comment.