Skip Menu |

This queue is for tickets about the Test-Log4perl CPAN distribution.

Report information
The Basics
Id: 45660
Status: new
Priority: 0/
Queue: Test-Log4perl

People
Owner: Nobody in particular
Requestors: clkao [...] clkao.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Fwd: [PATCH] - s/Test::Logger/Test::Log4perl/; - allow the expect helper to pass arguments to Test::Log4perl->start
Date: Sun, 3 May 2009 20:59:38 +0800
To: bug-test-log4perl [...] rt.cpan.org
From: Chia-liang Kao <clkao [...] clkao.org>
---  README               |   16 ++++++++--------  lib/Test/Log4perl.pm |   23 ++++++++++++++++-------  2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/README b/README index 5517173..1231cc5 100644 --- a/README +++ b/README @@ -24,13 +24,13 @@ SYNOPSIS       # test that those things matched       Test::Log4perl->end("Test that that logs okay"); - -      # we also have a simplified version: + +  # we also have a simplified version:       { -        my $foo = Test::Logger->expect(['foo.bar.quux', warn => qr/hello/ ]); +        my $foo = Test::Log4perl->expect(['foo.bar.quux', warn => qr/hello/ ]);         # ... do something that should log 'hello'       } -      # $foo goes out of scope; this triggers the test. +      # $foo goes out of scope; this triggers the test.  DESCRIPTION     This module can be used to test that you're logging the right thing with @@ -75,15 +75,15 @@ DESCRIPTION   Methods     get_logger($category) -        Returns a new instance of Test::Logger that can be used to log +        Returns a new instance of Test::Log4perl that can be used to log         expected messages in the category passed. -    Test::Logger->expect(['dotted.path', 'warn' => qr'this', 'warn' => -    qr'that'], ..) +    Test::Log4perl->expect(%start_args, ['dotted.path', 'warn' => qr'this', +    'warn' => qr'that'], ..)         Class convenience method. Used like this:           { # start local scope -            my $foo = Test::Logger->expect(['foo.bar.quux', warn => qr/hello/ ]); +            my $foo = Test::Log4perl->expect(['foo.bar.quux', warn => qr/hello/ ]);             # ... do something that should log 'hello'           } # $foo goes out of scope; this triggers the test. diff --git a/lib/Test/Log4perl.pm b/lib/Test/Log4perl.pm index 9cd183d..bbeecc4 100644 --- a/lib/Test/Log4perl.pm +++ b/lib/Test/Log4perl.pm @@ -13,7 +13,7 @@ use Carp qw(croak);  use Scalar::Util qw(blessed);  use Log::Log4perl qw(:levels); -our $VERSION = '0.1001'; +our $VERSION = '0.1002';  =head1 NAME @@ -46,7 +46,7 @@ Test::Log4perl - test log4perl   # we also have a simplified version:   { -    my $foo = Test::Logger->expect(['foo.bar.quux', warn => qr/hello/ ]); +    my $foo = Test::Log4perl->expect(['foo.bar.quux', warn => qr/hello/ ]);     # ... do something that should log 'hello'   }   # $foo goes out of scope; this triggers the test. @@ -100,7 +100,7 @@ should do the comparisons.  =item get_logger($category) -Returns a new instance of Test::Logger that can be used to log +Returns a new instance of Test::Log4perl that can be used to log  expected messages in the category passed.  =cut @@ -113,21 +113,30 @@ sub get_logger   return $self;  } -=item Test::Logger->expect(['dotted.path', 'warn' => qr'this', 'warn' => qr'that'], ..) +=item Test::Log4perl->expect(%start_args, ['dotted.path', 'warn' => qr'this', 'warn' => qr'that'], ..)  Class convenience method. Used like this:   { # start local scope -    my $foo = Test::Logger->expect(['foo.bar.quux', warn => qr/hello/ ]); +    my $foo = Test::Log4perl->expect(['foo.bar.quux', warn => qr/hello/ ]);     # ... do something that should log 'hello'   } # $foo goes out of scope; this triggers the test.  =cut  sub expect { -  my ($class, @expects) = @_; +  my $class = shift; +  my (@start_args, @expects); +  for (@_) { +      if (ref($_) eq 'ARRAY') { +          push @expects, $_; +      } +      else { +          push @start_args, $_; +      } +  } +  $class->start(@start_args);   my @loggers; -  $class->start(ignore_priority => "info");   for (@expects) {       my $name = shift @$_;       my $tlogger = $class->get_logger($name); -- 1.6.3.rc2.8.gbe66