Commit | Line | Data |
67d7bb36 |
1 | #original bug report https://rt.cpan.org/Public/Bug/Display.html?id=83267 |
2 | |
496782e0 |
3 | #The following code from Module::Metadata 1.000011 exposed the bug |
67d7bb36 |
4 | #BEGIN { |
5 | # if ($INC{'Log/Contextual.pm'}) { |
6 | # Log::Contextual->import('log_info'); |
7 | # } else { |
8 | # *log_info = sub (&) { warn $_[0]->() }; |
9 | # } |
10 | #} |
11 | |
496782e0 |
12 | use Test::More qw(no_plan); |
13 | |
14 | BEGIN { |
15 | if (0) { |
16 | eval { |
17 | package NotMain; |
18 | |
19 | use strict; |
20 | use warnings; |
21 | use Test::More; |
22 | use Log::Contextual::SimpleLogger; |
23 | |
24 | use Log::Contextual qw(:log), |
25 | -default_logger => Log::Contextual::SimpleLogger->new({ levels => [qw( )] }); |
26 | |
27 | eval { log_info { "Yep" } }; |
28 | is($@, '', 'Invoked log function in package other than main'); |
29 | }; |
30 | |
31 | is($@, '', 'non-main package subtest did not die'); |
32 | } |
33 | } |
34 | |
35 | package main; |
36 | |
37 | use strict; |
38 | use warnings; |
39 | use Test::More; |
67d7bb36 |
40 | |
41 | #bug report does not include a case where Log::Contextual is |
42 | #brought in via 'use' |
43 | require Log::Contextual; |
44 | |
45 | #try to import a single log function but do not include any tags |
46 | eval { Log::Contextual->import('log_info') }; |
496782e0 |
47 | is($@, '', 'Imported log function with out dying'); |
48 | |
49 | eval { log_info { "test" } 1 }; |
50 | is($@, '', 'Was able to invoke log function'); |