X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FImport-Into.git;a=blobdiff_plain;f=t%2Fimport_into.t;h=e9ebb9c1efb4b06238f6457ee013400a9c746881;hp=504dcbe921e69d65868021c2444371d41566d8b3;hb=8afc1658ff5a85afc7418d2779a4b4113feb4466;hpb=2afb5246467e98519cbc8df4025dd6e4a929a85d diff --git a/t/import_into.t b/t/import_into.t index 504dcbe..e9ebb9c 100644 --- a/t/import_into.t +++ b/t/import_into.t @@ -1,6 +1,6 @@ use strict; use warnings FATAL => 'all'; -use Test::More; +use Test::More qw(no_plan); BEGIN { @@ -20,33 +20,67 @@ BEGIN { my $target = caller; warnings->import::into($target); MyExporter->import::into($target, 'thing'); + CheckFile->import::into(1); + } $INC{"MultiExporter.pm"} = 1; } +my @checkcaller; +my $checkversion; BEGIN { + package CheckFile; + + sub import { + @checkcaller = caller; + } + sub VERSION { + $checkversion = $_[1]; + } + + $INC{"CheckFile.pm"} = 1; +} + +eval q{ + package TestPackage; no warnings; +#line 1 "import_into_inline.pl" use MultiExporter; sub test { thing . undef } -} + 1; +} or die $@; my @w; is(do { local $SIG{__WARN__} = sub { push @w, @_; }; - TestPackage::test; + TestPackage::test(); }, 'thing', 'returned thing ok'); is(scalar @w, 1, 'Only one entry in @w'); like($w[0], qr/uninitialized/, 'Correct warning'); -done_testing; +is $checkcaller[0], 'TestPackage', 'import by level has correct package'; +is $checkcaller[1], 'import_into_inline.pl', 'import by level has correct file'; +is $checkcaller[2], 1, 'import by level has correct line'; + +CheckFile->import::into({ + package => 'ExplicitPackage', + filename => 'explicit-file.pl', + line => 42, + version => 219, +}); + +is $checkcaller[0], 'ExplicitPackage', 'import with hash has correct package'; +is $checkcaller[1], 'explicit-file.pl', 'import with hash has correct file'; +is $checkcaller[2], 42, 'import with hash has correct line'; +is $checkversion, 219, 'import with hash has correct version';