File: LvalueAttributes.pm

package info (click to toggle)
libmason-perl 2.24-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 748 kB
  • sloc: perl: 4,882; makefile: 7
file content (30 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package Mason::t::LvalueAttributes;
$Mason::t::LvalueAttributes::VERSION = '2.24';
use Test::Class::Most parent => 'Mason::Test::Class';

__PACKAGE__->default_plugins( [ '@Default', 'LvalueAttributes' ] );

sub test_lvalue : Tests {
    my $self = shift;
    $self->test_comp(
        src => '
<%class>
has "a" => (is => "rw");
has "b" => (is => "ro");

</%class>

<%init>
$.a = 5;
print "a = " . $.a . "\n";
$.a(6);
print "a = " . $.a . "\n";
eval { $.b = 6 };
print $@ . "\n";
</%init>
',
        expect => qr/a = 5\na = 6\nCan't modify.*/,
    );
}

1;