File: 10_bad_use.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 (54 lines) | stat: -rw-r--r-- 517 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!perl -w

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

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

fieldhash my %hash;

eval{
	$hash{foo}++;
};
ok $@;

eval{
	$hash{1}++;
};
ok $@;

eval{
	my $o = {};
	$hash{"$o"}++;
};
ok $@;

eval{
	exists $hash{foo};
};

ok $@;

eval{
	my $x = $hash{foo};
};
ok $@;

eval{
	delete $hash{foo};
};
ok $@;

eval{
	fieldhashes [];
};
ok $@;

my $o = {foo => 'bar'};
{
	fieldhash my %hash;
	$hash{$o} = 42;
}

is_deeply $o, {foo => 'bar'};