diff options
author | Michael G. Schwern <schwern@pobox.com> | 2001-05-29 01:42:59 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-05-28 22:52:11 +0000 |
commit | 82d4508f1e378a1fc682f730ff20d4be8c3772e5 (patch) | |
tree | 4bf14ec6fcee3b796df0658522ad95378b61b019 /t | |
parent | 3253b43b0591bebee9032edaaf8ca10a35d99eed (diff) | |
download | perl-82d4508f1e378a1fc682f730ff20d4be8c3772e5.tar.gz |
Re: [ID 20010528.001] use autouse 'URI::Escape' => qw(URI::Escape::uri_escape) failed
Message-ID: <20010529004259.A675@blackrider.blackstar.co.uk>
p4raw-id: //depot/perl@10271
Diffstat (limited to 't')
-rw-r--r-- | t/pragma/autouse.t | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/t/pragma/autouse.t b/t/pragma/autouse.t index dbd44086fa..0120ed0899 100644 --- a/t/pragma/autouse.t +++ b/t/pragma/autouse.t @@ -1,18 +1,53 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +use Test; +BEGIN { plan tests => 9; } + BEGIN { - chdir 't' if -d 't'; - @INC = '../lib'; + require autouse; + eval { + "autouse"->import('List::Util' => 'List::Util::first'); + }; + ok( $@, qr/^autouse into different package attempted/ ); + + "autouse"->import('List::Util' => qw(max first(&@))); } -print "1..3\n"; +my @a = (1,2,3,4,5.5); +ok( max(@a), 5.5); -use autouse 'Math::Complex' => qw(cplx); -use autouse 'Math::Trig' => qw(Math::Trig::deg2grad($;$)); -print "ok 1\n"; +# first() has a prototype of &@. Make sure that's preserved. +ok( (first { $_ > 3 } @a), 4); + + +# Example from the docs. +use autouse 'Carp' => qw(carp croak); + +{ + my @warning; + local $SIG{__WARN__} = sub { push @warning, @_ }; + carp "this carp was predeclared and autoused\n"; + ok( scalar @warning, 1 ); + ok( $warning[0], "this carp was predeclared and autoused\n" ); + + eval { croak "It is but a scratch!" }; + ok( $@, qr/^It is but a scratch!/); +} + -print "not " unless sqrt(cplx(-1)) == cplx(0, 1); -print "ok 2\n"; +# Test that autouse's lazy module loading works. We assume that nothing +# involved in this test uses Test::Soundex, which is pretty safe. +use File::Spec; +use autouse 'Text::Soundex' => qw(soundex); -print "not " unless Math::Trig::deg2grad(360, 1) == 400; -print "ok 3\n"; +my $mod_file = File::Spec->catfile(qw(Text Soundex.pm)); +ok( !exists $INC{$mod_file} ); +ok( soundex('Basset'), 'B230' ); +ok( exists $INC{$mod_file} ); |