File Coverage

blib/lib/Test/DeepFile.pm
Criterion Covered Total %
statement 29 29 100.0
branch 6 6 100.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 43 43 100.0


line stmt bran cond sub pod time code
1             package Test::DeepFile;
2              
3 1     1   41071 use 5.010000;
  1         4  
  1         40  
4 1     1   6 use strict;
  1         2  
  1         36  
5 1     1   11 use warnings;
  1         7  
  1         35  
6 1     1   5 use Test::More;
  1         2  
  1         5  
7 1     1   1321 use Test::Deep;
  1         14708  
  1         289  
8              
9 1     1   959 use YAML qw (LoadFile DumpFile);
  1         9227  
  1         370  
10              
11             require Exporter;
12              
13             our @ISA = qw(Exporter);
14              
15             # Items to export into callers namespace by default. Note: do not export
16             # names by default without a very good reason. Use EXPORT_OK instead.
17             # Do not simply export all your public functions/methods/constants.
18              
19             # This allows declaration use Test::DeepFile ':all';
20             # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
21             # will save memory.
22             our %EXPORT_TAGS = ( 'all' => [ qw(
23             ) ] );
24              
25             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
26              
27             our @EXPORT = qw(
28             cmp_deeply_file
29             );
30              
31             our $VERSION = '0.003';
32              
33             our %seen;
34              
35             sub cmp_deeply_file
36             {
37 5 100   5 1 15779 die "usage: cmp_deeply_file( expect, name);" unless @_ == 2;
38 4         11 my ($d1, $name) = @_;
39 4 100       26 die "All ready tested $name" if $seen{$name};
40 3         133 $seen{$name} = 1;
41 3         11 my $filename = "t/deepfile/$name.data";
42            
43 3 100       105 if (-r $filename) {
44 1         7 my $d2 = LoadFile $filename;
45 1         13671 cmp_deeply($d1, $d2, $name);
46             } else {
47 2         22 mkdir 't/deepfile/';
48 2         13 DumpFile $filename, $d1;
49 2         18930 pass("Created $filename");
50             }
51             }
52              
53             1;
54             __END__