improved the test for bug 83267
[p5sagit/Log-Contextual.git] / t / regression_83267.t
CommitLineData
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 12use Test::More qw(no_plan);
13
14BEGIN {
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
35package main;
36
37use strict;
38use warnings;
39use Test::More;
67d7bb36 40
41#bug report does not include a case where Log::Contextual is
42#brought in via 'use'
43require Log::Contextual;
44
45#try to import a single log function but do not include any tags
46eval { Log::Contextual->import('log_info') };
496782e0 47is($@, '', 'Imported log function with out dying');
48
49eval { log_info { "test" } 1 };
50is($@, '', 'Was able to invoke log function');