typo fix in docs
[p5sagit/Import-Into.git] / t / import_into.t
CommitLineData
2afb5246 1use strict;
2use warnings FATAL => 'all';
1615d435 3use Test::More qw(no_plan);
2afb5246 4
5BEGIN {
6
7 package MyExporter;
8
9 use base qw(Exporter);
10
11 our @EXPORT_OK = qw(thing);
12
13 sub thing { 'thing' }
14
15 package MultiExporter;
16
17 use Import::Into;
18
19 sub import {
20 my $target = caller;
21 warnings->import::into($target);
22 MyExporter->import::into($target, 'thing');
e5f9555d 23 CheckFile->import::into(1);
2afb5246 24 }
25
26 $INC{"MultiExporter.pm"} = 1;
27}
28
e5f9555d 29my @checkcaller;
30BEGIN {
31
32 package CheckFile;
33
34 sub import {
35 @checkcaller = caller;
36 }
37
38 $INC{"CheckFile.pm"} = 1;
39}
40
2afb5246 41BEGIN {
42
43 package TestPackage;
44
45 no warnings;
46
e5f9555d 47#line 1
2afb5246 48 use MultiExporter;
49
50 sub test {
51 thing . undef
52 }
53}
54
55my @w;
56
57is(do {
58 local $SIG{__WARN__} = sub { push @w, @_; };
59 TestPackage::test;
60}, 'thing', 'returned thing ok');
61
62is(scalar @w, 1, 'Only one entry in @w');
63
64like($w[0], qr/uninitialized/, 'Correct warning');
e5f9555d 65
66is $checkcaller[0], 'TestPackage', 'import by level has correct package';
67is $checkcaller[1], __FILE__, 'import by level has correct file';
68is $checkcaller[2], 1, 'import by level has correct line';