File: 09_info_more.t

package info (click to toggle)
libtest-leaktrace-perl 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 412 kB
  • ctags: 879
  • sloc: ansic: 3,215; perl: 1,789; makefile: 7
file content (35 lines) | stat: -rw-r--r-- 786 bytes parent folder | download | duplicates (6)
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
#!perl -w

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

use Test::LeakTrace qw(:all);
use autouse 'Data::Dumper' => 'Dumper';

my @info = leaked_info{
	my %a = (foo => 42);
	my %b;

	$b{bar} = 3.14;

	{
		$b{a} = \%a;
	}
	$a{b} = \%b;
};

cmp_ok(scalar(@info), '>', 2)
	or diag(Dumper \@info);

is_deeply [grep{ eq_array [$_->[0]], [\42]   } @info], [ [\42,   __FILE__, 10] ];
is_deeply [grep{ eq_array [$_->[0]], [\3.14] } @info], [ [\3.14, __FILE__, 13] ];

my(@x) = grep{ my $r = $_->[0]; ref($r) eq 'REF' && ref(${$r}) eq 'HASH' && exists ${$r}->{b} } @info;

is scalar(@x), 1 or diag(Dumper \@x);
is $x[0][2], 16; # line

(@x) = grep{ my $r = $_->[0]; ref($r) eq 'REF' && ref(${$r}) eq 'HASH' && exists ${$r}->{a} } @info;

is scalar(@x), 1 or diag(Dumper \@x);
is $x[0][2], 18; # line