Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test for RT #71356: readonly trait for private attributes
  • Loading branch information
timo committed Dec 10, 2012
1 parent b8d4388 commit 1fa9ddf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion S06-traits/is-readonly.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 12;
plan 14;

# L<S06/"Parameter traits"/"=item is readonly">
# should be moved with other subroutine tests?
Expand Down Expand Up @@ -54,4 +54,15 @@ plan 12;
'dies on assignment to (my $x is readonly)';
}

# RT #71356
{
class C {
has $!attr is readonly = 71356;
method get-attr() { $!attr }
method set-attr($val) { $!attr = $val }
}
is C.new.get-attr, 71356, 'can read from readonly private attributes';
dies_ok { my $c = C.new; $c.set-attr: 99; }, 'cannot assign to readonly private attribute'
}

# vim: ft=perl6

0 comments on commit 1fa9ddf

Please sign in to comment.