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