From: Tyler Riddle Date: Tue, 12 Feb 2013 16:26:45 +0000 (-0800) Subject: improved the test for bug 83267 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=496782e085e3fc4908b0bd8361b81be40064abf3;p=p5sagit%2FLog-Contextual.git improved the test for bug 83267 --- diff --git a/t/regression_83267.t b/t/regression_83267.t index 36bb76e..0f8d99d 100644 --- a/t/regression_83267.t +++ b/t/regression_83267.t @@ -1,10 +1,6 @@ -use strict; -use warnings; -use Test::More qw(no_plan); - #original bug report https://rt.cpan.org/Public/Bug/Display.html?id=83267 -#The following code from Module::Metadata exposed the bug +#The following code from Module::Metadata 1.000011 exposed the bug #BEGIN { # if ($INC{'Log/Contextual.pm'}) { # Log::Contextual->import('log_info'); @@ -13,6 +9,34 @@ use Test::More qw(no_plan); # } #} +use Test::More qw(no_plan); + +BEGIN { + if (0) { + eval { + package NotMain; + + use strict; + use warnings; + use Test::More; + use Log::Contextual::SimpleLogger; + + use Log::Contextual qw(:log), + -default_logger => Log::Contextual::SimpleLogger->new({ levels => [qw( )] }); + + eval { log_info { "Yep" } }; + is($@, '', 'Invoked log function in package other than main'); + }; + + is($@, '', 'non-main package subtest did not die'); + } +} + +package main; + +use strict; +use warnings; +use Test::More; #bug report does not include a case where Log::Contextual is #brought in via 'use' @@ -20,4 +44,7 @@ require Log::Contextual; #try to import a single log function but do not include any tags eval { Log::Contextual->import('log_info') }; -ok(! $@, 'Imported log function correctly'); +is($@, '', 'Imported log function with out dying'); + +eval { log_info { "test" } 1 }; +is($@, '', 'Was able to invoke log function');