File Coverage

inc/MyTestFramework.pm
Criterion Covered Total %
statement 31 35 88.5
branch 4 6 66.6
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 42 49 85.7


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