line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AutoCode::Compare; |
2
|
5
|
|
|
5
|
|
25
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
162
|
|
3
|
5
|
|
|
5
|
|
97
|
use AutoCode::Root; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
26
|
|
4
|
|
|
|
|
|
|
our @ISA=qw(AutoCode::Root); |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our @REGULAR_REF=qw(SCALAR ARRAY HASH); |
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
24
|
use constant FALSE=>0; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
327
|
|
9
|
5
|
|
|
5
|
|
24
|
use constant TRUE =>1; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
4151
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub equal { |
12
|
1
|
|
|
1
|
0
|
3
|
my ($class, @array)=@_; |
13
|
1
|
|
|
|
|
2
|
my @refs=map{ref($_)}@array; |
|
2
|
|
|
|
|
6
|
|
14
|
1
|
50
|
|
|
|
10
|
return 0 unless $refs[0] eq $refs[1]; |
15
|
1
|
|
|
|
|
3
|
my $ref=$refs[0]; |
16
|
1
|
50
|
|
|
|
6
|
if($ref eq ''){ |
17
|
1
|
|
|
|
|
7
|
return $array[0] eq $array[1]; |
18
|
|
|
|
|
|
|
} |
19
|
0
|
|
|
|
|
|
my ($x, $y)=@array; |
20
|
0
|
0
|
|
|
|
|
return TRUE if ref($x) eq ref($y); |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
if(grep /^$ref$/, @REGULAR_REF){ |
23
|
0
|
|
|
|
|
|
my $method="equal_\L$ref"; |
24
|
0
|
|
|
|
|
|
return $class->$method(@array); |
25
|
|
|
|
|
|
|
}else{ |
26
|
0
|
|
|
|
|
|
return $class->equal_object(@array); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub equal_scalar { |
31
|
0
|
|
|
0
|
0
|
|
my $class=shift; |
32
|
0
|
|
|
|
|
|
my @scalars=map{my $z=$_; ${$z}}@_; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $class->equal(@scalars); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub equal_array { |
37
|
0
|
|
|
0
|
0
|
|
my $class=shift; |
38
|
0
|
|
|
|
|
|
my ($x, $y)=@_; |
39
|
0
|
|
|
|
|
|
my @x=@$x; |
40
|
0
|
|
|
|
|
|
my @y=@$y; |
41
|
0
|
|
|
|
|
|
my $max=scalar(@x); |
42
|
0
|
0
|
|
|
|
|
return FALSE unless $max == scalar(@y); |
43
|
0
|
0
|
|
|
|
|
return TRUE if $max==0; |
44
|
0
|
|
|
|
|
|
for(my $i=0; $i<$max; $i++){ |
45
|
0
|
0
|
|
|
|
|
return FALSE unless $class->equal($x[$i], $y[$i]); |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
return TRUE; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub equal_hash { |
51
|
0
|
|
|
0
|
0
|
|
my $class=shift; |
52
|
0
|
|
|
|
|
|
my ($x, $y)=@_; |
53
|
0
|
|
|
|
|
|
my %x=%$x; |
54
|
0
|
|
|
|
|
|
my %y=%$y; |
55
|
0
|
|
|
|
|
|
my @keys=keys %x; |
56
|
0
|
|
|
|
|
|
my $max=scalar(@keys); |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
return FALSE unless $max==scalar(keys %y); |
59
|
0
|
0
|
|
|
|
|
return TRUE if $max==0; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $found=0; |
62
|
0
|
|
|
|
|
|
foreach (@keys){ |
63
|
0
|
0
|
|
|
|
|
$found++ if exists $y{$_}; |
64
|
|
|
|
|
|
|
} |
65
|
0
|
0
|
|
|
|
|
return FALSE unless $found==$max; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
foreach my $key(@keys){ |
68
|
0
|
0
|
|
|
|
|
return FALSE unless $class->equal($x{$key}, $y{$key}); |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
return TRUE; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub equal_obj { |
74
|
0
|
|
|
0
|
0
|
|
my $class=shift; |
75
|
0
|
|
|
|
|
|
my @array=@_; |
76
|
0
|
|
|
|
|
|
my ($x)=@_; |
77
|
0
|
|
|
|
|
|
my $string="$x"; |
78
|
0
|
|
|
|
|
|
$string =~ /^([^=]*=)?(\w+)\((\w+)\)$/; |
79
|
0
|
|
|
|
|
|
my $internal_structure=$2; |
80
|
0
|
|
|
|
|
|
local $_=$internal_structure; |
81
|
0
|
0
|
|
|
|
|
if(/^ARRAY$/){ |
|
|
0
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return $class->equal_array(@array); |
83
|
|
|
|
|
|
|
}elsif(/^HASH$/){ |
84
|
0
|
|
|
|
|
|
return $class->equal_hash(@_); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|