X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FExporter.t;h=c90a4608d9dad11d51aed0c907c40c3cdf83bce8;hb=2b63cd5cea47e4bc97380284adf9fb0e89f7c10c;hp=54150685a75e779601e1b382696a8cedd286cd67;hpb=364e1267e1c01598947ebb286e5e925f56a6bee9;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Exporter.t b/lib/Exporter.t index 5415068..c90a460 100644 --- a/lib/Exporter.t +++ b/lib/Exporter.t @@ -1,4 +1,4 @@ -#!./perl +#!./perl -w BEGIN { chdir 't' if -d 't'; @@ -21,7 +21,7 @@ sub ok ($;$) { } -print "1..26\n"; +print "1..28\n"; require Exporter; ok( 1, 'Exporter compiled' ); @@ -75,7 +75,7 @@ $seat = 'seat'; BEGIN {*is = \&Is}; sub Is { 'Is' }; -Exporter::export_ok_tags; +Exporter::export_ok_tags(); my %tags = map { $_ => 1 } map { @$_ } values %EXPORT_TAGS; my %exportok = map { $_ => 1 } @EXPORT_OK; @@ -102,7 +102,7 @@ my $got = eval {&lifejacket}; # Testing->import is called. ::ok( eval "defined &is", "Import a subroutine where exporter must create the typeglob" ); -my $got = eval "&is"; +$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') @@ -182,17 +182,35 @@ package Moving::Target; @ISA = qw(Exporter); @EXPORT_OK = qw (foo); -sub foo {"foo"}; -sub bar {"bar"}; +sub foo {"This is foo"}; +sub bar {"This is bar"}; package Moving::Target::Test; -Moving::Target->import (foo); +Moving::Target->import ('foo'); -::ok (foo eq "foo", "imported foo before EXPORT_OK changed"); +::ok (foo() eq "This is foo", "imported foo before EXPORT_OK changed"); push @Moving::Target::EXPORT_OK, 'bar'; -Moving::Target->import (bar); +Moving::Target->import ('bar'); + +::ok (bar() eq "This is bar", "imported bar after EXPORT_OK changed"); + +package The::Import; + +use Exporter 'import'; + +eval { import() }; +::ok(\&import == \&Exporter::import, "imported the import routine"); + +@EXPORT = qw( wibble ); +sub wibble {return "wobble"}; + +package Use::The::Import; + +The::Import->import; + +my $val = eval { wibble() }; +::ok($val eq "wobble", "exported importer worked"); -::ok (bar eq "bar", "imported bar after EXPORT_OK changed");