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=4fcf9cad7028f1714d554ee91c1248235daa4d85;hp=bc323fb795a1d16d90b6e69d1823a7e0a8bd7976;hb=568eef3eaba8968cd37b29f669648c302bf7ac60;hpb=1615d435a41a6924d7a853bcbadd470fc5039fc3 diff --git a/t/import_into.t b/t/import_into.t index bc323fb..4fcf9ca 100644 --- a/t/import_into.t +++ b/t/import_into.t @@ -20,17 +20,36 @@ 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; +} + BEGIN { package TestPackage; no warnings; +#line 1 use MultiExporter; sub test { @@ -48,3 +67,19 @@ is(do { 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[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';