File Coverage

blib/lib/Test/Perl/Tags.pm
Criterion Covered Total %
statement 21 21 100.0
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             package Test::Perl::Tags;
2              
3 6     6   246443 use strict; use warnings;
  6     6   16  
  6         246  
  6         40  
  6         10  
  6         222  
4 6     6   5911 use parent 'Test::Builder::Module';
  6         1934  
  6         32  
5              
6 6     6   7965 use Path::Tiny 'path';
  6         104022  
  6         2136  
7              
8             our @EXPORT = qw(tag_ok);
9             our $VERSION = '0.32';
10              
11             =head1 NAME
12            
13             Test::Perl::Tags - testing output of L<Perl::Tags>
14            
15             =head1 SYNOPSIS
16            
17             use Test::Perl::Tags;
18            
19             # do some tagging
20            
21             tag_ok $tagger,
22             SYMBOL => 'path/to/file.pm' => 'searchable bookmark',
23             'Description of this test';
24            
25             tag_ok $tagger,
26             SYMBOL => 'path/to/file.pm' => 'searchable bookmark' => 'p' => 'line:3' => 'class:Test',
27             'Add additional parameters for exuberant extension';
28            
29             =cut
30              
31             sub tag_ok {
32 27     27 0 11408     my ($tagger, $symbol, $path, $bookmark) = splice(@_, 0, 4);
33 27         45     my $description = pop;
34              
35 27         106     my $canonpath = path($path)->absolute->canonpath;
36              
37 27         1950     my $tag = join "\t",
38                     $symbol,
39                     $canonpath,
40                     "/$bookmark/";
41              
42             # exuberant extensions
43 27 100       98     if (@_) {
44 4         13         $tag .= join "\t",
45                         q<;">,
46                         @_;
47                 }
48              
49 27         680     my $ok = $tagger =~ /
50             ^
51             \Q$tag\E
52             $
53             /mx;
54 27         163     my $builder = __PACKAGE__->builder;
55              
56 27 50       258     $builder->ok( $ok, $description )
57                     or $builder->diag( "Tags did not match:\n$tag" );
58             }
59              
60             1;
61