File: 001-basic.t

package info (click to toggle)
libdevel-stacktrace-withlexicals-perl 2.01-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 224 kB
  • sloc: perl: 1,531; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 746 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 4;
use Devel::StackTrace::WithLexicals;

my $stack = Devel::StackTrace::WithLexicals->new(unsafe_ref_capture=>1);
is($stack->frame_count, 1);

my $frame = $stack->frame(0);
is_deeply($frame->lexicals, {});

my @array = (1, 2);
my %hash = (key => 'value');
my $aref = [1, 2];
my $href = {key => 'value'};

# now another stack trace, this time with lexicals!
my $stack2 = Devel::StackTrace::WithLexicals->new(unsafe_ref_capture=>1);
is($stack2->frame_count, 1);

my $frame2 = $stack2->frame(0);
is_deeply($frame2->lexicals, {
    '$stack' => \$stack,
    '$frame' => \$frame,
    '@array' => \@array,
    '%hash'  => \%hash,
    '$aref'  => \$aref,
    '$href'  => \$href,
});