# Check that the effects of loading Errno::AnyString materialize in other
# already-loaded modules. Errno.pm loading = <<< vary!!loadhow!!none,use,evaluse,implicit >>>
use strict;
use warnings;
<<< IF loadhow == 'use' ->>>
use Errno;
<<< ELSIF loadhow == 'evaluse' ->>>
eval "use Errno"; die $@ if $@;
<<< ELSIF loadhow == 'implicit' ->>>
my @implicitly_load_Errno_pm = keys(%!);
<<< END ->>>
use Test::More;
use Test::NoWarnings;
use lib 't';
use Foo1;
use Foo2;
use Foo3;
use Foo4;
use Errno::AnyString qw/CUSTOM_ERRSTR_ERRNO custom_errstr/;
my @pkgs = map {"Foo$_"} (1 .. 4);
plan tests => @pkgs*6 + <<< vary!!taint ? 2 : 1 >>>;
<<< IF vary!!local >>>local $!;<<< END >>>
foreach my $pkg (@pkgs) {
my $x = $pkg->new;
$! = custom_errstr "string1";
is $x->errstr, "string1", "$pkg special errstr set";
is $x->errno, CUSTOM_ERRSTR_ERRNO, "$pkg special errno set";
my $save = $!;
$! = 0;
isnt $x->errstr, "string1", "$pkg special errstr unset";
isnt $x->errno, CUSTOM_ERRSTR_ERRNO, "$pkg special errno unset";
$! = $save;
is $x->errstr, "string1", "$pkg special errstr restored";
is $x->errno, CUSTOM_ERRSTR_ERRNO, "$pkg special errno restored";
}