-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase coverage by checking other cases
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |