File: 04_copy.t

package info (click to toggle)
libhash-fieldhash-perl 0.15-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 296 kB
  • sloc: perl: 1,249; ansic: 207; makefile: 10
file content (40 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (7)
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
#!perl -w

use strict;
use Test::More tests => 12;

#use Hash::Util::FieldHash::Compat qw(:all);
use Hash::FieldHash qw(:all);

fieldhashes \my(%a, %b, %c);

{
	my $o = {};
	my $p = {};
	$a{$o} = 42;
	$a{$p} = 3.14;
	%b = %a;

	is_deeply [sort values %a], [sort 42, 3.14];
	is_deeply [sort values %b], [sort 42, 3.14];

	$a{$o}++;
	is_deeply [sort values %a], [sort 43, 3.14];
	is_deeply [sort values %b], [sort 42, 3.14];

	%b = %a;
	is_deeply [sort values %a], [sort 43, 3.14];
	is_deeply [sort values %b], [sort 43, 3.14];

	%c = %b;
	is_deeply [sort values %c], [sort 43, 3.14];

	%c = ();
	is_deeply [sort values %a], [sort 43, 3.14];
	is_deeply [sort values %b], [sort 43, 3.14];
	is_deeply \%c, {};
}

is_deeply \%a, {};
is_deeply \%b, {};