File: 025_partial_clone.t

package info (click to toggle)
libreadonlyx-perl 1.04-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: perl: 577; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 509 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!perl -I../../lib
# Verify partial clones of Readonly vars are mutable
use strict;
use Test::More;
use ReadonlyX;
use Test::Fatal;
#
Readonly::Scalar our $MAP => {'record' => {id    => 1,
                                           title => 'Record',
                              }
};
my $map_partial_copy = Readonly::Clone $MAP->{record};
is exception {
    $map_partial_copy->{id} = 42;
}, undef, 'create mutalbe copy';
#
is $map_partial_copy->{id}, 42, 'mutable copy is... well, mutable';
#
done_testing;