diff options
author | glasser@tang-eleven-seventy-nine.mit.edu <glasser@tang-eleven-seventy-nine.mit.edu> | 2005-04-20 19:28:14 +0000 |
---|---|---|
committer | Dave Mitchell <davem@fdisolutions.com> | 2005-04-20 21:47:40 +0000 |
commit | f2a7f2982c10dbcfc2084d281af6ad8b959d5fb9 (patch) | |
tree | a7074d1d39356ac19f8d88c5f86c5bd529a64384 /t/op/caller.t | |
parent | 4944113acaf494b4518ba93648e0a4276c34a175 (diff) | |
download | perl-f2a7f2982c10dbcfc2084d281af6ad8b959d5fb9.tar.gz |
[perl #35059] [PATCH] caller() skips frames (such as eval() frames) if $^P set
From: glasser@tang-eleven-seventy-nine.mit.edu (via RT) <perlbug-followup@perl.org>
Message-Id: <rt-3.0.11-35059-111134.0.304511316819145@perl.org>
improved version of change 21842 that copes with glob DB::sub
existing but &DB::sub not existing.
p4raw-id: //depot/perl@24265
Diffstat (limited to 't/op/caller.t')
-rw-r--r-- | t/op/caller.t | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/t/op/caller.t b/t/op/caller.t index 4d90aeafd3..578aaaf0d8 100644 --- a/t/op/caller.t +++ b/t/op/caller.t @@ -5,7 +5,7 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; - plan( tests => 27 ); + plan( tests => 31 ); } my @c; @@ -87,3 +87,32 @@ sub testwarn { BEGIN { is( ${^WARNING_BITS}, "UUUUUUUUUUUU", 'warning bits on via "use warnings::register"' ) } testwarn("UUUUUUUUUUUU","#3"); } + + +# The next two cases test for a bug where caller ignored evals if +# the DB::sub glob existed but &DB::sub did not (for example, if +# $^P had been set but no debugger has been loaded). The tests +# thus assume that there is no &DB::sub: if there is one, they +# should both pass no matter whether or not this bug has been +# fixed. + +my $debugger_test = q< + my @stackinfo = caller(0); + return scalar @stackinfo; +>; + +sub pb { return (caller(0))[3] } + +my $i = eval $debugger_test; +is( $i, 10, "do not skip over eval (and caller returns 10 elements)" ); + +is( eval 'pb()', 'main::pb', "actually return the right function name" ); + +my $saved_perldb = $^P; +$^P = 16; +$^P = $saved_perldb; + +$i = eval $debugger_test; +is( $i, 10, 'do not skip over eval even if $^P had been on at some point' ); +is( eval 'pb()', 'main::pb', 'actually return the right function name even if $^P had been on at some point' ); + |