From: Vincent Pit Date: Sun, 17 May 2009 19:03:20 +0000 (+0200) Subject: A better way to check for pure-Perl versions X-Git-Tag: v0.06~3 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=f7b302bf589ab54e52386465432ccd1ec995e60c;p=perl%2Fmodules%2FScalar-Vec-Util.git A better way to check for pure-Perl versions Inspired from Test::NoXS. --- diff --git a/t/02-pp.t b/t/02-pp.t index a4d5f0f..dea9f2b 100644 --- a/t/02-pp.t +++ b/t/02-pp.t @@ -8,16 +8,17 @@ use Config qw/%Config/; use Test::More tests => 4; BEGIN { - my $re = join '|', - grep defined && length, - @Config{qw/myarchname archname/}, 'arch'; - my @inc = @INC; - @INC = grep !/(?:$re)$/, @INC; - require Scalar::Vec::Util; - Scalar::Vec::Util->import(qw/vfill vcopy veq SVU_PP/); - @INC = @inc; + require XSLoader; + my $xsloader_load_orig = \&XSLoader::load; + no warnings 'redefine'; + *XSLoader::load = sub { + die if $_[0] eq 'Scalar::Vec::Util'; + goto $xsloader_load_orig; + }; } +use Scalar::Vec::Util qw/vfill vcopy veq SVU_PP/; + is(SVU_PP, 1, 'using pure perl subroutines'); for (qw/vfill vcopy veq/) { no strict 'refs';