summaryrefslogtreecommitdiff
path: root/lib/Exporter.t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2001-12-16 17:24:55 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-17 17:20:51 +0000
commitd7341064bc2472128b060451c0da8ce62db49d9d (patch)
tree725481171525f57a8004ef259396faefce6f146e /lib/Exporter.t
parent3fe0b9a92b23bfc87b2e318dbb8d3f5cd834b8b4 (diff)
downloadperl-d7341064bc2472128b060451c0da8ce62db49d9d.tar.gz
Exporter.t (and question)
Message-ID: <20011216172455.P21702@plum.flirble.org> p4raw-id: //depot/perl@13728
Diffstat (limited to 'lib/Exporter.t')
-rw-r--r--lib/Exporter.t24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/Exporter.t b/lib/Exporter.t
index f2771db3f5..d2a9289c61 100644
--- a/lib/Exporter.t
+++ b/lib/Exporter.t
@@ -21,7 +21,7 @@ sub ok ($;$) {
}
-print "1..19\n";
+print "1..24\n";
require Exporter;
ok( 1, 'Exporter compiled' );
@@ -50,7 +50,7 @@ foreach my $meth (@::Exporter_Methods) {
That => [qw(Above the @wailing)],
tray => [qw(Fasten $seatbelt)],
);
-@EXPORT = qw(lifejacket);
+@EXPORT = qw(lifejacket is);
@EXPORT_OK = qw(under &your $seat);
$VERSION = '1.05';
@@ -72,6 +72,8 @@ $seat = 'seat';
@wailing = qw(AHHHHHH);
%left = ( left => "right" );
+BEGIN {*is = \&Is};
+sub Is { 'Is' };
Exporter::export_ok_tags;
@@ -89,6 +91,24 @@ Testing->import;
::ok( defined &lifejacket, 'simple import' );
+my $got = eval {&lifejacket};
+::ok ( $@ eq "", 'check we can call the imported subroutine')
+ or print STDERR "# \$\@ is $@\n";
+::ok ( $got eq 'lifejacket', 'and that it gave the correct result')
+ or print STDERR "# expected 'lifejacket', got " .
+ (defined $got ? "'$got'" : "undef") . "\n";
+
+# The string eval is important. It stops $Foo::{is} existing when
+# Testing->import is called.
+::ok( eval "defined &is",
+ "Import a subroutine where exporter must create the typeglob" );
+my $got = eval "&is";
+::ok ( $@ eq "", 'check we can call the imported autoloaded subroutine')
+ or chomp ($@), print STDERR "# \$\@ is $@\n";
+::ok ( $got eq 'Is', 'and that it gave the correct result')
+ or print STDERR "# expected 'Is', got " .
+ (defined $got ? "'$got'" : "undef") . "\n";
+
package Bar;
my @imports = qw($seatbelt &Above stuff @wailing %left);