1*898184e3Ssthen#!perl 2*898184e3Ssthen 3*898184e3Ssthenuse strict; 4*898184e3Ssthenuse warnings; 5*898184e3Ssthen 6*898184e3Ssthenuse Test::More tests => 31; 7*898184e3Ssthen 8*898184e3Ssthenuse_ok('XS::APItest'); 9*898184e3Ssthen 10*898184e3Ssthenmy $method = 0; 11*898184e3Ssthenmy @types = map { 'gv_autoload' . $_ } qw( 4 _sv _pv _pvn ); 12*898184e3Ssthen 13*898184e3Ssthensub AUTOLOAD { 14*898184e3Ssthen our $AUTOLOAD; 15*898184e3Ssthen my ($subname, $message) = @_; 16*898184e3Ssthen is $subname, $AUTOLOAD, $message; 17*898184e3Ssthen} 18*898184e3Ssthen 19*898184e3Ssthenmy $sub = "nothing"; 20*898184e3Ssthen 21*898184e3Ssthenok my $glob = XS::APItest::gv_autoload_type(\%::, $sub, 1, $method); 22*898184e3Ssthen*{$glob}{CODE}->( __PACKAGE__ . "::" . $sub, '$AUTOLOAD set correctly' ); 23*898184e3Ssthen 24*898184e3Ssthen$sub = "some_sub"; 25*898184e3Ssthenfor my $type ( 0..3 ) { 26*898184e3Ssthen is $glob = XS::APItest::gv_autoload_type(\%::, $sub, $type, $method), "*main::AUTOLOAD", "*main::AUTOLOAD if autoload is true in $types[$type]."; 27*898184e3Ssthen *{$glob}{CODE}->( __PACKAGE__ . "::" . $sub, '$AUTOLOAD set correctly' ); 28*898184e3Ssthen} 29*898184e3Ssthen 30*898184e3Ssthen$sub = "method\0not quite!"; 31*898184e3Ssthen 32*898184e3Ssthenok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 0, $method); 33*898184e3Ssthen*{$glob}{CODE}->( __PACKAGE__ . "::" . $sub, "gv_autoload4() is nul-clean"); 34*898184e3Ssthen 35*898184e3Ssthenok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 1, $method); 36*898184e3Ssthen*{$glob}{CODE}->( __PACKAGE__ . "::" . $sub, "gv_autoload_sv() is nul-clean"); 37*898184e3Ssthen 38*898184e3Ssthenok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 2, $method); 39*898184e3Ssthen*{$glob}{CODE}->( __PACKAGE__ . "::" . ($sub =~ s/\0.*//r), "gv_autoload_pv() is not nul-clean"); 40*898184e3Ssthen 41*898184e3Ssthenok $glob = XS::APItest::gv_autoload_type(\%::, $sub, 3, $method); 42*898184e3Ssthen*{$glob}{CODE}->( __PACKAGE__ . "::" . $sub, "gv_autoload_pvn() is nul-clean"); 43*898184e3Ssthen 44*898184e3Ssthen{ 45*898184e3Ssthen use utf8; 46*898184e3Ssthen use open qw( :utf8 :std ); 47*898184e3Ssthen 48*898184e3Ssthen package main; 49*898184e3Ssthen 50*898184e3Ssthen sub AUTOLOAD { 51*898184e3Ssthen our $AUTOLOAD; 52*898184e3Ssthen my ($subname, $message) = @_; 53*898184e3Ssthen ::is $subname, $AUTOLOAD, $message; 54*898184e3Ssthen } 55*898184e3Ssthen 56*898184e3Ssthen for my $type ( 1..3 ) { 57*898184e3Ssthen ::ok $glob = XS::APItest::gv_autoload_type(\%main::, $sub = "method", $type, $method); 58*898184e3Ssthen *{$glob}{CODE}->( "main::" . $sub, "$types[$type]() is UTF8-clean when both the stash and the sub are in UTF-8"); 59*898184e3Ssthen ::ok $glob = XS::APItest::gv_autoload_type(\%main::, $sub = "method", $type, $method); 60*898184e3Ssthen *{$glob}{CODE}->( "main::" . $sub, "$types[$type]() is UTF8-clean when only the stash is in UTF-8"); 61*898184e3Ssthen } 62*898184e3Ssthen} 63