summaryrefslogtreecommitdiff
path: root/lib/utf8.t
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utf8.t')
-rw-r--r--lib/utf8.t25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/utf8.t b/lib/utf8.t
index 8e2b8ea00e..e6c94e6dc4 100644
--- a/lib/utf8.t
+++ b/lib/utf8.t
@@ -563,4 +563,29 @@ for my $pos (0..5) {
is($s, "A\xc8\x81\xe8\xab\x86","(pos $pos) str after U; utf8::encode");
}
+# [perl #119043] utf8::upgrade should not croak on read-only COWs
+for(__PACKAGE__) {
+ # First make sure we have a COW, otherwise this test is useless.
+ my $copy = $_;
+ my @addrs = unpack "L!L!", pack "pp", $copy, $_;
+ if ($addrs[0] != $addrs[1]) {
+ fail("__PACKAGE__ did not produce a COW - if this change was "
+ ."intentional, please provide me with another ro COW scalar")
+ }
+ else {
+ eval { utf8::upgrade($_) };
+ is $@, "", 'no error with utf8::upgrade on read-only COW';
+ }
+}
+# This one croaks, but not because the scalar is read-only
+eval "package \x{100};\n" . <<'END'
+ for(__PACKAGE__) {
+ eval { utf8::downgrade($_) };
+ ::like $@, qr/^Wide character/,
+ 'right error with utf8::downgrade on read-only COW';
+ }
+ 1
+END
+or die $@;
+
done_testing();