summaryrefslogtreecommitdiff
path: root/t/op/caller.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-08-27 22:38:57 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-08-27 23:24:03 -0700
commit19bcb54e626c56999bd22347f278ae81abf0eb1c (patch)
tree9a5f83593cf5d83a3a89ed97d5b9a61ec2854a74 /t/op/caller.t
parent11076590cd9927694bccd96456ab149a3a7bb432 (diff)
downloadperl-19bcb54e626c56999bd22347f278ae81abf0eb1c.tar.gz
Stop (caller $n)[6] from including final "\n;"
String eval appends "\n;" to the string before evaluating it. (caller $n)[6], which returns the text of the eval, was giving the modified string, rather than the original. In fact, it was returning the actual string buffer that the parser uses. This commit changes it to create a new mortal SV from that string buffer, but without the last two characters. It unfortunately breaks this JAPH: eval'BEGIN{${\(caller 2)[6]}=~y< !"$()+\-145=ACHMT^acfhinrsty{}> <nlrhta"o Pe e,\nkrcrJ uthspeia">}say if+chr(1) -int"145"!=${^MATCH}'
Diffstat (limited to 't/op/caller.t')
-rw-r--r--t/op/caller.t9
1 files changed, 8 insertions, 1 deletions
diff --git a/t/op/caller.t b/t/op/caller.t
index 09d33f3876..8c8c236289 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 => 86 );
+ plan( tests => 88 );
}
my @c;
@@ -266,6 +266,13 @@ foo::bar
END
"No crash when freed stash is reused for PV with offset hack";
+is eval "(caller 0)[6]", "(caller 0)[6]",
+ 'eval text returned by caller does not include \n;';
+
+# PL_linestr should not be modifiable
+eval '"${;BEGIN{ ${\(caller 2)[6]} = *foo }}"';
+pass "no assertion failure after modifying eval text via caller";
+
$::testing_caller = 1;
do './op/caller.pl' or die $@;