1#!perl -w 2 3use Test::More tests => 19; 4 5use XS::APItest; 6 7for my $func ('SvPVbyte', 'SvPVutf8') { 8 $g = *glob; 9 $r = \1; 10 is &$func($g), '*main::glob', "$func(\$glob_copy)"; 11 is ref\$g, 'GLOB', "$func(\$glob_copy) does not flatten the glob"; 12 is &$func($r), "$r", "$func(\$ref)"; 13 is ref\$r, 'REF', "$func(\$ref) does not flatten the ref"; 14 15 is &$func(*glob), '*main::glob', "$func(*glob)"; 16 is ref\$::{glob}, 'GLOB', "$func(*glob) does not flatten the glob"; 17 is &$func($^V), "$^V", "$func(\$ro_ref)"; 18 is ref\$^V, 'REF', "$func(\$ro_ref) does not flatten the ref"; 19} 20 21eval 'SvPVbyte(*{chr 256})'; 22like $@, qr/^Wide character/, 'SvPVbyte fails on Unicode glob'; 23package r { use overload '""' => sub { substr "\x{100}\xff", -1 } } 24is SvPVbyte(bless [], r::), "\xff", 25 'SvPVbyte on ref returning downgradable utf8 string'; 26 27sub TIESCALAR { bless \(my $thing = pop), shift } 28sub FETCH { ${ +shift } } 29tie $tyre, main => bless [], r::; 30is SvPVbyte($tyre), "\xff", 31 'SvPVbyte on tie returning ref that returns downgradable utf8 string'; 32