File: compat.t

package info (click to toggle)
libreadonly-tiny-perl 4-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 108 kB
  • sloc: perl: 314; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 653 bytes parent folder | download
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
#!/usr/bin/perl

use warnings;
use strict;

use Test::More;
use t::Util;

use Readonly::Tiny qw/Readonly/;

Readonly my $x, 2;

is $x, 2,                   "Readonly assigns to scalar";
ok SvRO(\$x),               "Readonly makes scalar RO";

Readonly my @x, 1, 2, 3;

is_deeply \@x, [1, 2, 3],   "Readonly assigns to array";
ok SvRO(\@x),               "Readonly makes array RO";
ok SvRO(\$x[0]),            "Readonly makes array elem RO";

Readonly my %x, foo => 1;

is_deeply \%x, {foo => 1},  "Readonly assigns to hash";
ok SvRO(\%x),               "Readonly makes hash RO";
ok SvRO(\$x{foo}),          "Readonly makes hash elem RO";

done_testing;