summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-09-28 08:34:51 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-10-01 12:51:54 -0700
commit892f91270f2acad75eaf1abceabc8c50bf559b2d (patch)
treeb143ae196e5c720e8001565e75ea28d619319f93 /t
parent76f7f4d6a8494f1c7f0987fadbb555eb5a1103a1 (diff)
downloadperl-892f91270f2acad75eaf1abceabc8c50bf559b2d.tar.gz
Make utf8::encode respect magic
It has always ignored set-magic, as far as I can tell. Since the magic flags patch (4bac9ae47b), it has been ignor- ing get- magic on magical scalars that were already PVs. sv_utf8_upgrade_flags_grow begins with an if(!SvPOK(sv)) check, which used to mean ‘if this scalar is magic or not a string’, but now means simply ‘if this scalar is not a string’. SvPOK_nog is the new SvPOK. Due to the way the flags now work, I had to modify sv_pvutf8n_force as well, to keep existing tests passing.
Diffstat (limited to 't')
-rw-r--r--t/op/utf8magic.t11
1 files changed, 10 insertions, 1 deletions
diff --git a/t/op/utf8magic.t b/t/op/utf8magic.t
index 3d942c0cea..cc6936f392 100644
--- a/t/op/utf8magic.t
+++ b/t/op/utf8magic.t
@@ -6,7 +6,7 @@ BEGIN {
require './test.pl';
}
-plan tests => 4;
+plan tests => 5;
use strict;
@@ -23,3 +23,12 @@ $str =~ /(.)/;
ok !utf8::is_utf8($1), "is_utf8(bytes)";
scalar "$1"; # invoke SvGETMAGIC
ok !utf8::is_utf8($1), "is_utf8(bytes)";
+
+sub TIESCALAR { bless [pop] }
+sub FETCH { $_[0][0] }
+sub STORE { $::stored = pop }
+
+tie my $str2, "", "a";
+$str2 = "b";
+utf8::encode $str2;
+is $::stored, "a", 'utf8::encode respects get-magic on POK scalars';