Commit | Line | Data |
633048d5 |
1 | #!perl |
2 | use warnings FATAL => 'all'; |
3 | use strict; |
4 | |
5 | # Test that caller() works |
6 | |
7 | { |
8 | package Foo; |
9 | |
10 | use Test::More 'no_plan'; |
11 | |
12 | use Function::Parameters qw(:strict); |
13 | |
14 | sub sub_caller { |
15 | my($self, $level) = @_; |
16 | #line 13 |
17 | return caller($level); |
18 | } |
19 | |
20 | |
21 | sub sub_caller2 { |
22 | my($self, $level) = @_; |
23 | #line 20 |
24 | return $self->sub_caller($level); |
25 | } |
26 | |
27 | |
28 | method method_caller($level) { |
29 | #line 13 |
30 | return caller($level); |
31 | } |
32 | |
33 | |
34 | method method_caller2($level) { |
35 | #line 20 |
36 | return $self->method_caller($level); |
37 | } |
38 | |
39 | #line 36 |
40 | my @expected = Foo->sub_caller2(0); |
41 | my @expected2 = Foo->sub_caller2(1); |
42 | |
43 | #line 36 |
44 | my @have = Foo->method_caller2(0); |
45 | my @have2 = Foo->method_caller2(1); |
46 | |
47 | $expected[3] = 'Foo::method_caller'; |
48 | $expected2[3] = 'Foo::method_caller2'; |
49 | |
50 | is_deeply([@have[0..7]], [@expected[0..7]]); |
51 | is_deeply([@have2[0..7]], [@expected2[0..7]]); |
52 | |
53 | # hints and bitmask change and are twitchy so I'm just going to |
54 | # check that they're there. |
55 | isnt $have[8], undef; |
56 | isnt $have2[8], undef; |
57 | isnt $have[9], undef; |
58 | isnt $have2[9], undef; |
59 | } |