File: 07_alias_anon_array.t

package info (click to toggle)
libdata-alias-perl 1.28-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 368 kB
  • sloc: perl: 1,976; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 697 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
29
30
31
32
33
34
35
36
#!/usr/bin/perl -w

use strict;
use warnings qw( FATAL all NONFATAL void );
use lib 'lib';
use Test::More tests => 12;

use Data::Alias;

sub refs { [map "".\$_, @_] }

our $x = alias [];
is @$x, 0;

is_deeply alias([$_]), [$_]  for 1 .. 3;

$x = alias [42];
eval { $x->[0]++ };
like $@, qr/^Modification .* attempted /;

$x = alias [$x];
is_deeply refs(@$x), refs($x);

$x = alias [$x, our $y];
is_deeply refs(@$x), refs($x, $y);

$x = alias [$x, $y, our $z];
is_deeply refs(@$x), refs($x, $y, $z);

$x = alias [undef, $y, undef];
is @$x, 3;
is \$x->[1], \$y;
ok "$]" < 5.019004 ? !exists($x->[0]) : \$x->[0] eq \undef;
ok "$]" < 5.019004 ? !exists($x->[2]) : \$x->[2] eq \undef;

# vim: ft=perl