File Coverage

inc/MyTestFramework.pm
Criterion Covered Total %
statement 28 32 87.5
branch 4 6 66.6
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 38 45 84.4


line stmt bran cond sub pod time code
1             package MyTestFramework;
2 2     2   52139 use strict;
  2         6  
  2         94  
3 2     2   2020 use Test::Base -base;
  2         78465  
  2         19  
4 2     2   2648 use HTTP::Request::FromTemplate;
  2     2   5  
  2     2   85  
  2         13  
  2         3  
  2         91  
  2         1571  
  2         6  
  2         16  
5            
6             our @EXPORT = qw(template_identity);
7            
8             sub template_identity {
9 3     3 0 34583 my $block = shift;
10            
11 3         16 my $expected = $block->expected;
12 3         38 my $template = $block->template;
13            
14             # Normalize the data because Test::Base screws it up
15 3         32 for ($expected,$template) {
16 6         68 s!\r?\n!\n!g;
17 6 100       33 if ($_ !~ m!\n\n!m) { # Header without a body
18 4         30 $_ .= "\n"
19             until m!\n\n$!m;
20             };
21             };
22            
23 3         56 my $h = HTTP::Request::FromTemplate->new(template => \$template);
24            
25             # A bug in Test::Base - it eats all empty lines at
26             # the end of every block.
27 3 50       72 if ($expected !~ m!\n\n!m) { # Header without a body
28 0         0 $expected .= "\n"
29             until $expected =~ m!\n\n$!m;
30             };
31            
32 3         23 my $req = $h->process($block->data);
33 3         94 my $result = $req->as_string;
34            
35 3 50       2279 if ($block->name =~ /^TODO: (.*)/) {
36 0         0 TODO: {
37 0         0 local $TODO = $1;
38 0         0 is $result, $expected, $block->name;
39             };
40             } else {
41 3         58 is $result, $expected, $block->name;
42             };
43             }
44            
45             1;