Skip to content

Commit

Permalink
Respect no_refs in WithLexicals
Browse files Browse the repository at this point in the history
  • Loading branch information
sartak committed Dec 11, 2009
1 parent f8a7d91 commit 65e620b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Devel/StackTrace/WithLexicals.pm
Expand Up @@ -22,6 +22,12 @@ sub _record_caller_data {
next if $sub eq '(eval)';

$self->{raw}[$caller]{lexicals} = peek_my(++$walker);
if ($self->{no_refs}) {
for (values %{ $self->{raw}[$caller]{lexicals} }) {
$_ = $$_ if ref($_) eq 'REF';
$_ = $self->_ref_as_string($_);
}
}
}

# don't want to include the frame for this method!
Expand Down
21 changes: 21 additions & 0 deletions t/004-no-refs.t
@@ -0,0 +1,21 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 7;
use Devel::StackTrace::WithLexicals;

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

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

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

my $frame2 = $stack2->frame(0);
is(ref($frame2->lexicals->{'$stack'}), '');
is(ref($frame2->lexicals->{'$frame'}), '');
like($frame2->lexicals->{'$stack'}, qr/^Devel::StackTrace::WithLexicals=HASH\(0x\w+\)$/);
like($frame2->lexicals->{'$frame'}, qr/^Devel::StackTrace::WithLexicals::Frame=HASH\(0x\w+\)$/);

0 comments on commit 65e620b

Please sign in to comment.