5 if ($Config::Config{'extensions'} !~ m!\bList/Util\b!){
6 print "1..0 # Skip -- Perl configured without List::Util module\n";
12 BEGIN { plan tests => 12; }
17 "autouse"->import('List::Util' => 'List::Util::first(&@)');
22 "autouse"->import('List::Util' => 'Foo::min');
24 ok( $@, qr/^autouse into different package attempted/ );
26 "autouse"->import('List::Util' => qw(max first(&@)));
29 my @a = (1,2,3,4,5.5);
33 # first() has a prototype of &@. Make sure that's preserved.
34 ok( (first { $_ > 3 } @a), 4);
37 # Example from the docs.
38 use autouse 'Carp' => qw(carp croak);
42 local $SIG{__WARN__} = sub { push @warning, @_ };
43 carp "this carp was predeclared and autoused\n";
44 ok( scalar @warning, 1 );
45 ok( $warning[0], qr/^this carp was predeclared and autoused\n/ );
47 eval { croak "It is but a scratch!" };
48 ok( $@, qr/^It is but a scratch!/);
52 # Test that autouse's lazy module loading works.
53 use autouse 'Errno' => qw(EPERM);
55 my $mod_file = 'Errno.pm'; # just fine and portable for %INC
56 ok( !exists $INC{$mod_file} );
57 ok( EPERM ); # test if non-zero
58 ok( exists $INC{$mod_file} );
60 use autouse Env => "something";
62 ok( $@, qr/^\Qautoused module Env has unique import() method/ );
64 # Check that UNIVERSAL.pm doesn't interfere with modules that don't use
65 # Exporter and have no import() of their own.
67 autouse->import("Class::ISA" => 'self_and_super_versions');
68 my %versions = self_and_super_versions("Class::ISA");
69 ok( $versions{"Class::ISA"}, $Class::ISA::VERSION );