summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorgfx <gfuji@cpan.org>2010-04-25 22:02:09 +0200
committerRafael Garcia-Suarez <rgs@consttype.org>2010-04-25 22:02:09 +0200
commit76f730215a330c9eedad075cf13e470e97f62846 (patch)
treec803d1e6682bedca0691094abce5a70093de46db /t
parent39cf747a86645fde6898cd6d09d351d50755c2fa (diff)
downloadperl-76f730215a330c9eedad075cf13e470e97f62846.tar.gz
Fix utf8::is_utf8 to respect GMAGIC (e.g. $1)
Diffstat (limited to 't')
-rw-r--r--t/op/utf8magic.t19
1 files changed, 19 insertions, 0 deletions
diff --git a/t/op/utf8magic.t b/t/op/utf8magic.t
new file mode 100644
index 0000000000..2c915b716e
--- /dev/null
+++ b/t/op/utf8magic.t
@@ -0,0 +1,19 @@
+#!perl -w
+use strict;
+use Test::More;
+
+my $str = "\x{99f1}\x{99dd}"; # "camel" in Japanese kanji
+$str =~ /(.)/;
+
+ok utf8::is_utf8($1), "is_utf8(unistr)";
+scalar "$1"; # invoke SvGETMAGIC
+ok utf8::is_utf8($1), "is_utf8(unistr)";
+
+utf8::encode($str); # off the utf8 flag
+$str =~ /(.)/;
+
+ok !utf8::is_utf8($1), "is_utf8(bytes)";
+scalar "$1"; # invoke SvGETMAGIC
+ok !utf8::is_utf8($1), "is_utf8(bytes)";
+
+done_testing;