Skip to content

Commit

Permalink
Increase coverage by checking other cases
Browse files Browse the repository at this point in the history
  • Loading branch information
book committed Aug 11, 2005
1 parent cb93942 commit 08c9c1a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
9 changes: 9 additions & 0 deletions t/11bar.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use Test::More tests => 1;
use strict;
use t::Bar;

my $bar = Regexp::Log::Bar->new;
my $before = $bar->{_test};
my $re = $bar->regexp;
is( $bar->{_test}, $before + 1, 'postprocessing code executed');

33 changes: 33 additions & 0 deletions t/Bar.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package Regexp::Log::Bar;

use base qw( Regexp::Log );
use vars qw( $VERSION %DEFAULT %FORMAT %REGEXP );

$VERSION = 0.01;

# default values
%DEFAULT = (
format => '%d %c %b',
capture => [],
);

# predefined format strings
%FORMAT = ( ':default' => '%a %b %c', );

# the regexps that match the various fields
# this is the difficult part
%REGEXP = (
'%a' => '(?#=a)\\d+(?#!a)',
'%b' => '(?#=b)th(?:is|at)(?#!b)',
'%c' => '(?#=c)(?#=cs)\\w+(?#!cs)/(?#=cn)\\d+(?#!cn)(?#!c)',
'%d' => '(?#=d)(?:foo|bar|baz)(?#!d)',
);

sub _postprocess {
my $self = shift;

# some code here
$self->{_test}++;
}

1;

0 comments on commit 08c9c1a

Please sign in to comment.