subst.t: Test something I nearly broke
authorFather Chrysostomos <sprout@cpan.org>
Mon, 26 Nov 2012 17:40:34 +0000 (09:40 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 27 Nov 2012 15:05:04 +0000 (07:05 -0800)
The saving and restoring of $@ when utf8 tables were looked up was
causing pp_subst’s string pointers to go stale.  The existing mechanism
of copying it temporarily to another scalar was already very fragile,
and the new COW mechanism broke it (but I fixed it in the same commit
that introduced the new COW mechanism).

t/re/subst.t

index b139812..8acd54f 100644 (file)
@@ -7,7 +7,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan( tests => 205 );
+plan( tests => 206 );
 
 $_ = 'david';
 $a = s/david/rules/r;
@@ -881,3 +881,8 @@ $a = "";
 utf8::upgrade $a;
 $_ =~ s/$/$a/;
 is $_, "\xc4\x80", "empty utf8 repl does not result in mangled utf8";
+
+$@ = "\x{30cb}eval 18";
+$@ =~ s/eval \d+/eval 11/;
+is $@, "\x{30cb}eval 11",
+  'loading utf8 tables does not interfere with matches against $@';