summaryrefslogtreecommitdiff
path: root/t/04codelocation.t
blob: 917fed6ae3fa176bb7ddcd84cf90ee8bd7543afb (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

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' );
}