File: 10_bad_use.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 (42 lines) | stat: -rw-r--r-- 590 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
36
37
38
39
40
41
42
#!perl -w

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

use Test::LeakTrace;

for(1 .. 2){
	eval{
		my @a = leaked_refs{
			my @b = leaked_refs{
				my %a = (foo => 42);
				my %b = (bar => 3.14);

				$b{a} = \%a;
				$a{b} = \%b;
			};
		};
	};
	isnt $@, '', 'multi leaktrace';

	eval{
		leaktrace{
			my %a = (foo => 42);
			my %b = (bar => 3.14);

			$b{a} = \%a;
			$a{b} = \%b;
		} sub {
			die ['foo'];
		};
	};
	is_deeply $@, ['foo'], 'die in callback';

	eval{
		leaktrace{
			my @array;
			push @array, \@array;
		} -foobar;
	};
	like $@, qr/Invalid reporting mode/, 'invalid mode';
}