7 if (($Config::Config{'extensions'} !~ m!\bList/Util\b!) ){
8 print "1..0 # Skip -- Perl configured without List::Util module\n";
14 BEGIN { plan tests => 12; }
19 "autouse"->import('List::Util' => 'List::Util::first(&@)');
24 "autouse"->import('List::Util' => 'Foo::min');
26 ok( $@, qr/^autouse into different package attempted/ );
28 "autouse"->import('List::Util' => qw(max first(&@)));
31 my @a = (1,2,3,4,5.5);
35 # first() has a prototype of &@. Make sure that's preserved.
36 ok( (first { $_ > 3 } @a), 4);
39 # Example from the docs.
40 use autouse 'Carp' => qw(carp croak);
44 local $SIG{__WARN__} = sub { push @warning, @_ };
45 carp "this carp was predeclared and autoused\n";
46 ok( scalar @warning, 1 );
47 ok( $warning[0], qr/^this carp was predeclared and autoused\n/ );
49 eval { croak "It is but a scratch!" };
50 ok( $@, qr/^It is but a scratch!/);
54 # Test that autouse's lazy module loading works. We assume that nothing
55 # involved in this test uses Text::Soundex, which is pretty safe.
56 use autouse 'Text::Soundex' => qw(soundex);
58 my $mod_file = 'Text/Soundex.pm'; # just fine and portable for %INC
59 ok( !exists $INC{$mod_file} );
60 ok( soundex('Basset'), 'B230' );
61 ok( exists $INC{$mod_file} );
63 use autouse Env => "something";
65 ok( $@, qr/^\Qautoused module Env has unique import() method/ );
67 # Check that UNIVERSAL.pm doesn't interfere with modules that don't use
68 # Exporter and have no import() of their own.
70 autouse->import("Class::ISA" => 'self_and_super_versions');
71 my %versions = self_and_super_versions("Class::ISA");
72 ok( $versions{"Class::ISA"}, $Class::ISA::VERSION );