-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrace.t
52 lines (42 loc) · 1.25 KB
/
trace.t
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
use Test::Stream;
use Test::Stream::XS qw/refcount test_caller/;
is_deeply(test_caller(1, 0, 0), undef, "Nothing to test_caller");
sub do_it_a { test_caller(@_) };
my $test_caller = do_it_a(1, 0, 0); my $LINE = __LINE__;
is_deeply(
$test_caller,
[ __PACKAGE__, __FILE__, $LINE, 'main::do_it_a', 1 ],
"Got test_caller",
);
$test_caller = sub { do_it_a(1, 0, 0) }->(); $LINE = __LINE__;
is_deeply(
$test_caller,
[ __PACKAGE__, __FILE__, $LINE, 'main::do_it_a', 2 ],
"Got deeper test_caller",
);
$test_caller = sub { do_it_a(2, 0, 0) }->(); $LINE = __LINE__;
is_deeply(
$test_caller,
[ __PACKAGE__, __FILE__, $LINE, 'main::__ANON__', 2 ],
"Got deeper test_caller + level",
);
$test_caller = sub { do_it_a(5, 0, 0) }->(); $LINE = __LINE__;
is_deeply(
$test_caller,
undef,
"Bad Level",
);
$test_caller = sub { do_it_a(5, 0, 1) }->(); $LINE = __LINE__;
is_deeply(
$test_caller,
[ __PACKAGE__, __FILE__, $LINE, 'main::__ANON__', 2 ],
"Level with fudge",
);
$test_caller = sub { do_it_a(1, 1, 0) }->(); $LINE = __LINE__;
is_deeply(
$test_caller,
[ __PACKAGE__, __FILE__, $LINE, 'main::do_it_a', 1 ],
"Use wrap to hide some depth",
);
is(refcount($test_caller), 1, "1 ref to the test_caller");
done_testing;