File: 03readonly.t

package info (click to toggle)
libstruct-dumb-perl 0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 160 kB
  • sloc: perl: 468; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 307 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

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( dies { $point->y = 30 },
    '$point->y throws exception on readonly_struct' );

done_testing;