summaryrefslogtreecommitdiff
path: root/t/03readonly.t
blob: 57e938aee1d913d5be7febfc0d7502828bf92c6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use Test::Fatal;

use Struct::Dumb qw( readonly_struct );

readonly_struct Point => [qw( x y )];

my $point = Point(10, 20);

is( $point->x, 10, '$point->x is 10' );

ok( exception { $point->y = 30 },
    '$point->y throws exception on readonly_struct' );

done_testing;