X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fimport_into.t;h=fcf3c84dac4c284f8d4efd5b7869e99b02595c97;hb=08c85698b3db5e80cd3d0d44a698876a95f49797;hp=6bb30add4059cf4c5bbc458630073b2e342fb181;hpb=e5f9555dcd1499015a2ab8fa2623fca86d526405;p=p5sagit%2FImport-Into.git diff --git a/t/import_into.t b/t/import_into.t index 6bb30ad..fcf3c84 100644 --- a/t/import_into.t +++ b/t/import_into.t @@ -21,12 +21,14 @@ BEGIN { warnings->import::into($target); MyExporter->import::into($target, 'thing'); CheckFile->import::into(1); + } $INC{"MultiExporter.pm"} = 1; } my @checkcaller; +my $checkversion; BEGIN { package CheckFile; @@ -34,29 +36,33 @@ BEGIN { sub import { @checkcaller = caller; } + sub VERSION { + $checkversion = $_[1]; + } $INC{"CheckFile.pm"} = 1; } -BEGIN { +eval q{ package TestPackage; - no warnings; + no warnings FATAL => 'all'; -#line 1 +#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'); @@ -64,5 +70,17 @@ is(scalar @w, 1, 'Only one entry in @w'); like($w[0], qr/uninitialized/, 'Correct warning'); is $checkcaller[0], 'TestPackage', 'import by level has correct package'; -is $checkcaller[1], __FILE__, 'import by level has correct file'; +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';