From: Peter Rabbitson Date: Mon, 6 Sep 2010 17:19:41 +0000 (+0200) Subject: Correct string-eval (contained $) X-Git-Tag: v0.00305~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f929c548ead019d5801725e7ff78962c41c8ef94;p=p5sagit%2FLog-Contextual.git Correct string-eval (contained $) Rewrite test to whitstand line changes --- diff --git a/t/log4perl.t b/t/log4perl.t index d21d225..6d7e6aa 100644 --- a/t/log4perl.t +++ b/t/log4perl.t @@ -3,12 +3,15 @@ use warnings; use Test::More; -if (!eval "use Log::Log4perl; - die if $Log::Log4perl::VERSION < 1.29; - 1") { - plan skip_all => 'Log::Log4perl 1.29 not installed' -} else { +if (eval <<'EOE' +require Log::Log4perl; +die if $Log::Log4perl::VERSION < 1.29; +1 +EOE +) { plan tests => 2; +} else { + plan skip_all => 'Log::Log4perl 1.29 not installed' } use FindBin; @@ -17,16 +20,18 @@ Log::Log4perl->init("$FindBin::Bin/log4perl.conf"); use Log::Contextual qw( :log set_logger ); set_logger(Log::Log4perl->get_logger); -log_error { 'err 14' }; +my @elines; + +push @elines, __LINE__ and log_error { 'err FIRST' }; sub foo { - log_error { 'err 17' }; + push @elines, __LINE__ and log_error { 'err SECOND' }; } foo(); open my $log, '<', 'myerrs.log'; my @datas = <$log>; close $log; -is $datas[0], "file:t/log4perl.t line:20 method:main:: - err 14\n", 'file and line work with Log4perl'; -is $datas[1], "file:t/log4perl.t line:23 method:main::foo - err 17\n", 'file and line work with Log4perl in a sub'; +is $datas[0], "file:t/log4perl.t line:$elines[0] method:main:: - err FIRST\n", 'file and line work with Log4perl'; +is $datas[1], "file:t/log4perl.t line:$elines[1] method:main::foo - err SECOND\n", 'file and line work with Log4perl in a sub';