line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::File::Cmp;
|
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
113709
|
use 5.010;
|
|
2
|
|
|
|
|
13
|
|
4
|
2
|
|
|
2
|
|
9
|
use strict;
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
45
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings;
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
39
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
17
|
use File::Spec;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
45
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
8
|
use Test::Builder;
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
47
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
13
|
use Exporter 'import';
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
687
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.02';
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw(file_is);
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $Test = Test::Builder->new;
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub file_is($$;$) {
|
21
|
5
|
|
|
5
|
1
|
9735
|
my ($got_f, $exp_f, $name) = (_resolve(shift), _resolve(shift), shift);
|
22
|
5
|
|
66
|
|
|
17
|
$name //= "compare file '$got_f' with '$exp_f'";
|
23
|
5
|
|
|
|
|
6
|
my @got_lines = split(/\r?\n/, do { local (*ARGV, $/); @ARGV = ($got_f); <> });
|
|
5
|
|
|
|
|
26
|
|
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
365
|
|
24
|
5
|
|
|
|
|
15
|
my @exp_lines = split(/\r?\n/, do { local (*ARGV, $/); @ARGV = ($exp_f); <> });
|
|
5
|
|
|
|
|
45
|
|
|
5
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
260
|
|
25
|
5
|
100
|
|
|
|
19
|
if (@got_lines != @exp_lines) {
|
26
|
1
|
|
|
|
|
6
|
$Test->ok(0, $name);
|
27
|
1
|
|
|
|
|
764
|
$Test->diag(" Different number of lines");
|
28
|
1
|
|
|
|
|
184
|
return 0;
|
29
|
|
|
|
|
|
|
}
|
30
|
4
|
|
|
|
|
7
|
my $n = @got_lines;
|
31
|
4
|
|
|
|
|
11
|
for (my $i = 0; $i < $n; ++$i) {
|
32
|
10
|
|
|
|
|
18
|
my ($got, $exp) = ($got_lines[$i], $exp_lines[$i]);
|
33
|
10
|
100
|
|
|
|
25
|
if ($got ne $exp) {
|
34
|
1
|
|
|
|
|
4
|
$Test->ok(0, $name);
|
35
|
1
|
|
|
|
|
823
|
$Test->diag(" Files differ at line " . ($i + 1));
|
36
|
1
|
|
|
|
|
185
|
return 0;
|
37
|
|
|
|
|
|
|
}
|
38
|
|
|
|
|
|
|
}
|
39
|
3
|
|
|
|
|
12
|
return $Test->ok(1, $name);
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _resolve {
|
44
|
10
|
50
|
|
10
|
|
129
|
$_[0] =~ m{/} ? File::Spec->catfile(split(m{/}, shift)) : shift;
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; # End of Test::File::Cmp
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__
|