File: by_index.t

package info (click to toggle)
libdevel-backtrace-perl 0.12-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 180 kB
  • sloc: perl: 541; makefile: 7
file content (19 lines) | stat: -r--r--r-- 382 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!perl

use Test::More tests => 2;

use Devel::Backtrace;

sub get_caller_index {
    my $idx = shift;
    my $bt = Devel::Backtrace->new;
    return $bt->point(1)->by_index($idx);
}

my $sub = get_caller_index(3); # 3 is subroutine
is($sub, 'main::get_caller_index', 'field 3');

eval {
    get_caller_index(7000);
};
like($@, qr/There is no field with index 7000/, 'field 7000');