summaryrefslogtreecommitdiff
path: root/t/09-skip-frames.t
blob: 3834e68101b8ca11302049c8a6e4520e4fe94667 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use strict;
use warnings;

use Test::More;

use Devel::StackTrace;

{
    my $trace = baz();
    my @f;
    while ( my $f = $trace->next_frame ) { push @f, $f; }

    my $cnt = scalar @f;
    is(
        $cnt, 2,
        "Trace should have 2 frames"
    );

    is(
        $f[0]->subroutine, 'main::bar',
        "First frame subroutine should be main::bar"
    );
    is(
        $f[1]->subroutine, 'main::baz',
        "First frame subroutine should be main::baz"
    );
}

done_testing();

sub foo {
    return Devel::StackTrace->new( skip_frames => 2 );
}

sub bar {
    foo();
}

sub baz {
    bar();
}