6 use Test::More tests => 40;
11 my @types = map { 'gv_fetchmeth' . $_ } '', qw( _sv _pv _pvn );
13 sub test { "Sanity check" }
15 for my $type ( 0..3 ) {
17 XS::APItest::gv_fetchmeth_type(\%::, "test", $type, $level, 0)
18 }{CODE}->(), "Sanity check";
21 for my $type ( 0..3 ) {
22 my $meth = "gen$type";
23 ok !XS::APItest::gv_fetchmeth_type(\%::, $meth, $type, -1, 0), "With level = -1, $types[$type] returns false.";
24 ok !$::{$meth}, "...and doesn't vivify the glob.";
26 ok !XS::APItest::gv_fetchmeth_type(\%::, $meth, $type, 0, 0), "With level = 0, $types[$type] still returns false.";
27 ok $::{$meth}, "...but does vivify the glob.";
35 ok !XS::APItest::gv_fetchmeth_type(\%::, "method\0not quite!", 0, $level, 0), "gv_fetchmeth() is nul-clean";
36 ok !XS::APItest::gv_fetchmeth_type(\%::, "method\0not quite!", 1, $level, 0), "gv_fetchmeth_sv() is nul-clean";
37 is XS::APItest::gv_fetchmeth_type(\%::, "method\0not quite!", 2, $level, 0), "*main::method", "gv_fetchmeth_pv() is not nul-clean";
38 ok !XS::APItest::gv_fetchmeth_type(\%::, "method\0not quite!", 3, $level, 0), "gv_fetchmeth_pvn() is nul-clean";
42 use open qw( :utf8 :std );
49 "\357\275\215\357\275\205\357\275\224\357\275\210\357\275\217\357\275\204";
52 for my $type ( 1..3 ) {
53 ::is XS::APItest::gv_fetchmeth_type(\%main::, "method", $type, $level, 0), "*main::method", "$types[$type] is UTF-8 clean";
54 ::ok !XS::APItest::gv_fetchmeth_type(\%main::, $meth_as_octets, $type, $level, 0);
55 ::ok !XS::APItest::gv_fetchmeth_type(\%main::, "method", $type, $level, 0);
59 ::ok !XS::APItest::gv_fetchmeth_type(
60 \%{"\357\275\215\357\275\201\357\275\211\357\275\216::"},
61 "method", $type, $level, 0);
62 ::ok !XS::APItest::gv_fetchmeth_type(
63 \%{"\357\275\215\357\275\201\357\275\211\357\275\216::"},
64 "method", $type, $level, 0);