File: 03_copy.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 (44 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl -w

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

use Data::Alias 'copy';

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

is copy($_), $_  for 1 .. 3;

our $x = 42;
our $y = 43;
our $z = 44;

is copy($x), $x;
is copy { $x }, $x;
isnt \copy($x), \$x;
isnt \copy { $x }, \$x;

is_deeply [copy $x, $y, $z], [$x, $y, $z];
our @r = refs(copy $x, $y, $z);
isnt $r[0], \$x;
isnt $r[1], \$y;
isnt $r[2], \$z;

sub mortal { 42 }
sub nonmortal () { 42 }

$x = "".\mortal;
$y = "".\copy mortal;
is $x, $y;

$x = "".\nonmortal;
$y = "".\copy nonmortal;
isnt $x, $y;

$x = "".\scalar copy();
$y = "".\undef;
isnt $x, $y;

# vim: ft=perl