File: 21_alias_list_basic.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 (59 lines) | stat: -rw-r--r-- 1,146 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl -w

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

use Data::Alias;

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

our ($x, $y, $z);

is alias(($x) = ()), 0;
is \$x, \undef;
is_deeply refs(alias +($x) = ()), refs(undef);
is \$x, \undef;
is alias(($x) = $y), 1;
is \$x, \$y;
is_deeply refs(alias +($x) = $z), refs($z);
is \$x, \$z;
is alias(($x) = ($y, $z)), 2;
is \$x, \$y;
is_deeply refs(alias +($x) = ($z, $y)), refs($z);
is \$x, \$z;
is alias(($z, $y) = ($y, $z)), 2;
is \$x, \$y;

our $r = refs($y, $z);
is_deeply refs(alias +($z, $y) = ($y, $z)), $r;
is \$x, \$z;

$r = refs($y, $x, $z);
is_deeply refs(alias +($z, undef, $y) = ($y, $x, $z)), $r;
is \$x, \$y;

$r = *x;
is_deeply refs(alias +(undef, $$r, undef) = ($r, $z, $y)), refs($r, $z, $y);
is \$x, \$z;

alias { $x = my $foo };

our (@x, %x);
undef $r;
alias +($x[0], $x{0}, $$r) = ($x, $y, $z);
is \$x[0], \$x;
is \$x{0}, \$y;
is $r, \$z;

SKIP: {
no warnings 'deprecated';
skip "pseudo-hashes not supported anymore", 1 unless eval { [{1,1},1]->{1} };

$r = [{0=>1}];
alias +($r->{0}) = ($x);
is \$r->[1], \$x;
}

# vim: ft=perl