summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-31 13:04:57 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-31 13:15:39 -0800
commit4b0b99d26e495000677c5746dcab488fac511396 (patch)
treef2653c661b4d3027e5dae76d3047855bcc545b1e
parentfe46cbda823c09f80e4bc48dd93fafb26cc805f6 (diff)
downloadperl-4b0b99d26e495000677c5746dcab488fac511396.tar.gz
Test that SvPVutf8 works with magic vars
It didn’t until the previous commit.
-rw-r--r--MANIFEST2
-rw-r--r--ext/XS-APItest/t/svpv_magic.t20
2 files changed, 20 insertions, 2 deletions
diff --git a/MANIFEST b/MANIFEST
index 822c9aaad3..888b046e42 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4002,7 +4002,7 @@ ext/XS-APItest/t/stuff_modify_bug.t test for eval side-effecting source string
ext/XS-APItest/t/stuff_svcur_bug.t test for a bug in lex_stuff_pvn
ext/XS-APItest/t/sviscow.t Test SvIsCOW
ext/XS-APItest/t/svpeek.t XS::APItest extension
-ext/XS-APItest/t/svpv_magic.t Test behaviour of SvPVbyte and get magic
+ext/XS-APItest/t/svpv_magic.t Test behaviour of SvPVbyte/utf8 & get magic
ext/XS-APItest/t/svpv.t More generic SvPVbyte and SvPVutf8 tests
ext/XS-APItest/t/svsetsv.t Test behaviour of sv_setsv with/without PERL_CORE
ext/XS-APItest/t/swaplabel.t test recursive descent label parsing
diff --git a/ext/XS-APItest/t/svpv_magic.t b/ext/XS-APItest/t/svpv_magic.t
index 2ea6941abd..766c420349 100644
--- a/ext/XS-APItest/t/svpv_magic.t
+++ b/ext/XS-APItest/t/svpv_magic.t
@@ -1,6 +1,6 @@
#!perl -w
-use Test::More tests => 5;
+use Test::More tests => 9;
BEGIN {
use_ok('XS::APItest')
@@ -28,3 +28,21 @@ $b =~ /(.)/; # $1 shouldn't have the utf8 flag anymore
is(eval { XS::APItest::first_byte($1) } || $@, 0303,
"utf8 flag fetched correctly without stringification");
+
+sub TIESCALAR { bless [], shift }
+sub FETCH { ++$f; *{chr 255} }
+tie $t, "main";
+is SvPVutf8($t), "*main::\xc3\xbf",
+ 'SvPVutf8 works with get-magic changing the SV type';
+is $f, 1, 'SvPVutf8 calls get-magic once';
+
+package t {
+ @ISA = 'main';
+ sub FETCH { ++$::f; chr 255 }
+ sub STORE { }
+}
+tie $t, "t";
+undef $f;
+is SvPVutf8($t), "\xc3\xbf",
+ 'SvPVutf8 works with get-magic upgrading the SV';
+is $f, 1, 'SvPVutf8 calls get-magic once';