summaryrefslogtreecommitdiff
path: root/t/04codelocation-pureperl.t
blob: 04f6280a88dd39df63b846870b4326a24d83bd51 (plain)
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
#!perl
BEGIN { $ENV{PERL_SUB_IDENTIFY_PP} = 1 }
use Test::More tests => 6;
use Sub::Identify ':all';

sub newton {
    print;
    print;
    print;
    print;
    print;
    print;
    print;
}
*hooke = *newton;
for ( \&newton, \&hooke ) {
    my ($file, $line) = get_code_location($_);
    is( $file, $0, 'file' );
    is( $line, 7, 'line' );
}
{
    sub pauli;
    my ($file, $line) = get_code_location(\&pauli);
    ok( !defined $file, 'no definition, no file' );
    ok( !defined $line, 'no definition, no line' );
}