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