This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
autouse: fix autouse.t deparsing
authorDavid Mitchell <davem@iabyn.com>
Wed, 22 Nov 2017 17:38:42 +0000 (17:38 +0000)
committerDavid Mitchell <davem@iabyn.com>
Thu, 23 Nov 2017 08:52:16 +0000 (08:52 +0000)
autouse.t uses B as a random test XS module which it can defer loading.
However, B recently changed to not use Exporter, which upsets autouse:
but *only* when running under 't/TEST -deparse'. I'm not sure why it only
fails then, but in any case, this commit changes it so that it uses
Hash::Util instead.

dist/autouse/t/autouse.t

index a790403..20ad9eb 100644 (file)
@@ -98,13 +98,14 @@ SKIP: {
 SKIP: {
     skip "Fails in 5.15.5 and below (perl bug)", 1 if $] < 5.0150051;
     use Config;
 SKIP: {
     skip "Fails in 5.15.5 and below (perl bug)", 1 if $] < 5.0150051;
     use Config;
-    skip "no B", 1 unless $Config{extensions} =~ /\bB\b/;
+    skip "no Hash::Util", 1 unless $Config{extensions} =~ /\bHash::Util\b/;
     use warnings; local $^W = 1; no warnings 'once';
     my $w;
     local $SIG{__WARN__} = sub { $w .= shift };
     use warnings; local $^W = 1; no warnings 'once';
     my $w;
     local $SIG{__WARN__} = sub { $w .= shift };
-    use autouse B => "sv_undef";
-    *B::sv_undef = \&sv_undef;
-    require B;
+    # any old XS sub from any old module which uses Exporter
+    use autouse 'Hash::Util' => "all_keys";
+    *Hash::Util::all_keys = \&all_keys;
+    require Hash::Util;
     is $w, undef,
       'no redefinition warning when clobbering autouse stub with new XSUB';
 }
     is $w, undef,
       'no redefinition warning when clobbering autouse stub with new XSUB';
 }