From: Arthur Axel 'fREW' Schmidt Date: Sat, 20 Feb 2010 11:47:47 +0000 (-0600) Subject: more tests X-Git-Tag: v0.00100~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2580df543072fdc3c12e99efbfcc22843ab12b20;p=p5sagit%2FLog-Contextual.git more tests --- diff --git a/t/dlog.t b/t/dlog.t index 1439eba..2d4f118 100644 --- a/t/dlog.t +++ b/t/dlog.t @@ -8,7 +8,7 @@ my $var_log; BEGIN { $var_log = VarLogger->new } use Log::Contextual qw{:dlog}, -logger => $var_log; - +{ my @foo = Dlog_trace { "Look ma, data: $_" } qw{frew bar baz}; ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_trace passes data through correctly'); is( $var_log->var, <<'OUT', 'Output for Dlog_trace is correct'); @@ -26,8 +26,10 @@ tLook ma, data: [ "baz" ] OUT +} +{ my @foo = Dlog_debug { "Look ma, data: $_" } qw{frew bar baz}; ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_debug passes data through correctly'); is( $var_log->var, <<'OUT', 'Output for Dlog_debug is correct'); @@ -45,8 +47,10 @@ dLook ma, data: [ "baz" ] OUT +} +{ my @foo = Dlog_info { "Look ma, data: $_" } qw{frew bar baz}; ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_info passes data through correctly'); is( $var_log->var, <<'OUT', 'Output for Dlog_info is correct'); @@ -64,8 +68,10 @@ iLook ma, data: [ "baz" ] OUT +} +{ my @foo = Dlog_warn { "Look ma, data: $_" } qw{frew bar baz}; ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_warn passes data through correctly'); is( $var_log->var, <<'OUT', 'Output for Dlog_warn is correct'); @@ -83,8 +89,10 @@ wLook ma, data: [ "baz" ] OUT +} +{ my @foo = Dlog_error { "Look ma, data: $_" } qw{frew bar baz}; ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_error passes data through correctly'); is( $var_log->var, <<'OUT', 'Output for Dlog_error is correct'); @@ -102,8 +110,10 @@ eLook ma, data: [ "baz" ] OUT +} +{ my @foo = Dlog_fatal { "Look ma, data: $_" } qw{frew bar baz}; ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_fatal passes data through correctly'); is( $var_log->var, <<'OUT', 'Output for Dlog_fatal is correct'); @@ -121,4 +131,4 @@ fLook ma, data: [ "baz" ] OUT - +} diff --git a/t/simplelogger.t b/t/simplelogger.t index 772f03b..87ae8ca 100644 --- a/t/simplelogger.t +++ b/t/simplelogger.t @@ -2,12 +2,21 @@ use strict; use warnings; use Log::Contextual::SimpleLogger; -use Log::Contextual qw{:log} => -logger => +use Log::Contextual qw{:log set_logger} => -logger => Log::Contextual::SimpleLogger->new({levels => [qw{debug}]}); use Test::More qw(no_plan); my $l = Log::Contextual::SimpleLogger->new({levels => [qw{debug}]}); +ok(!$l->is_trace, 'is_trace is false on SimpleLogger'); ok($l->is_debug, 'is_debug is true on SimpleLogger'); +ok(!$l->is_info, 'is_info is false on SimpleLogger'); +ok(!$l->is_warn, 'is_warn is false on SimpleLogger'); +ok(!$l->is_error, 'is_error is false on SimpleLogger'); +ok(!$l->is_fatal, 'is_fatal is false on SimpleLogger'); -log_debug { 'set_logger' }; -log_trace { die 'this should live' }; +ok(eval { log_trace { die 'this should live' }; 1}, 'trace does not get called'); +ok(!eval { log_debug { die 'this should die' }; 1}, 'debug gets called'); +ok(eval { log_info { die 'this should live' }; 1}, 'info does not get called'); +ok(eval { log_warn { die 'this should live' }; 1}, 'warn does not get called'); +ok(eval { log_error { die 'this should live' }; 1}, 'error does not get called'); +ok(eval { log_fatal { die 'this should live' }; 1}, 'fatal does not get called');