summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2011-02-05 13:32:24 +0000
committerDavid Mitchell <davem@iabyn.com>2011-02-06 21:34:43 +0000
commit4b8811a5cd97a5737e826c610fd55a730539fbde (patch)
treee0c417bb76d97759a9bed8e974d3fb014ebc0aa2 /t
parent28b52d6a9d389ca6d1647f2c7db483631b898dc0 (diff)
downloadperl-4b8811a5cd97a5737e826c610fd55a730539fbde.tar.gz
pp_subtr: preserve UTF8 flag in rare cases
There are two main branches in pp_subtr(): the 'in-place' and the other, depending on whether the replacement string is short enough to be inserted directly. Commit 80b498e0aacf413fb7460d6882a74c68c1f9df48 back in 2000 changed a SvPOK_only() to a SvPOK_only_UTF8() to preserve the UTF8 bit, but only on *one* branch. Add the change to the other branch too. This will only make a difference in rare cases involving 'use bytes' (where it's arguably broken and generating malformed utf8 anyway); but the main reason for doing it is to allow soon for some identical code in the two branches to be de-duplicated.
Diffstat (limited to 't')
-rw-r--r--t/op/bop.t12
1 files changed, 11 insertions, 1 deletions
diff --git a/t/op/bop.t b/t/op/bop.t
index fdcded1fd5..238d2727fa 100644
--- a/t/op/bop.t
+++ b/t/op/bop.t
@@ -15,7 +15,7 @@ BEGIN {
# If you find tests are failing, please try adding names to tests to track
# down where the failure is, and supply your new names as a patch.
# (Just-in-time test naming)
-plan tests => 170 + (10*13*2) + 4;
+plan tests => 171 + (10*13*2) + 4;
# numerics
ok ((0xdead & 0xbeef) == 0x9ead);
@@ -441,6 +441,16 @@ SKIP: {
# it's really bogus that (~~malformed) is \0.
my $ref = "\x{10000}\0";
is(~~$str, $ref);
+
+ # same test, but this time with a longer replacement string that
+ # exercises a different branch in pp_subsr()
+
+ $str = "\x{10000}\x{800}";
+ { use bytes; $str =~ s/\C\C\z/\0\0\0/; }
+
+ # it's also bogus that (~~malformed) is \0\0\0\0.
+ my $ref = "\x{10000}\0\0\0\0";
+ is(~~$str, $ref, "use bytes with long replacement");
}
# ref tests