2 use warnings FATAL => 'all';
3 use Test::More qw(no_plan);
7 $INC{"MyExporter.pm"} = __FILE__;
11 our @EXPORT_OK = qw(thing);
21 $INC{"CheckFile.pm"} = __FILE__;
24 @importcaller = caller;
28 @versioncaller = caller;
33 package MultiExporter;
34 $INC{"MultiExporter.pm"} = __FILE__;
40 warnings->import::into($target);
41 MyExporter->import::into($target, 'thing');
42 CheckFile->import::into(1);
49 no warnings FATAL => 'all';
51 #line 1 "import_into_inline.pl"
63 local $SIG{__WARN__} = sub { push @w, @_; };
65 }, 'thing', 'returned thing ok');
67 is(scalar @w, 1, 'Only one entry in @w');
69 like($w[0], qr/uninitialized/, 'Correct warning');
71 is $importcaller[0], 'TestPackage',
72 'import by level has correct package';
73 is $importcaller[1], 'import_into_inline.pl',
74 'import by level has correct file';
75 is $importcaller[2], 1,
76 'import by level has correct line';
77 is scalar @versioncaller, 0, 'VERSION not called when not specified';
82 CheckFile->import::into({
83 package => 'ExplicitPackage',
84 filename => 'explicit-file.pl',
89 is $importcaller[0], 'ExplicitPackage',
90 'import with hash has correct package';
91 is $importcaller[1], 'explicit-file.pl',
92 'import with hash has correct file';
93 is $importcaller[2], 42,
94 'import with hash has correct line';
95 is $versioncaller[0], 'ExplicitPackage',
96 'VERSION with hash has correct package';
97 is $versioncaller[1], 'explicit-file.pl',
98 'VERSION with hash has correct file';
99 is $versioncaller[2], 42,
100 'VERSION with hash has correct line';
102 'import with hash has correct version';
105 package LevelExporter;
106 $INC{'LevelExporter.pm'} = __FILE__;
109 CheckFile->import::into({
120 package ExplicitLevel;
122 #line 42 "explicit-level.pl"
127 is $importcaller[0], 'ExplicitLevel',
128 'import with level in hash has correct package';
129 is $importcaller[1], 'explicit-level.pl',
130 'import with level in hash has correct file';
131 is $importcaller[2], 42,
132 'import with level in hash has correct line';
133 is $versioncaller[0], 'ExplicitLevel',
134 'VERSION with level in hash has correct package';
135 is $versioncaller[1], 'explicit-level.pl',
136 'VERSION with level in hash has correct file';
137 is $versioncaller[2], 42,
138 'VERSION with level in hash has correct line';
140 'import with level in hash has correct version';
142 ok( !IPC::Open3->can("open3"), "IPC::Open3 is unloaded" );
143 IPC::Open3->import::into("TestPackage");
144 ok( TestPackage->can("open3"), "IPC::Open3 was use'd and import::into'd" );