line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Expression::Operator::Binary::Eq; |
2
|
9
|
|
|
9
|
|
2106
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
9
|
|
|
9
|
|
10
|
|
|
9
|
|
|
9
|
|
201
|
|
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
35
|
|
|
9
|
|
|
|
|
186
|
|
|
9
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
291
|
|
3
|
9
|
|
|
9
|
|
29
|
use parent 'DTL::Fast::Expression::Operator::Binary'; |
|
9
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
42
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DTL::Fast::OPS_HANDLERS{'=='} = __PACKAGE__; |
6
|
|
|
|
|
|
|
|
7
|
9
|
|
|
9
|
|
467
|
use Scalar::Util qw(looks_like_number); |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
486
|
|
8
|
9
|
|
|
9
|
|
3904
|
use locale; |
|
9
|
|
|
|
|
4025
|
|
|
9
|
|
|
|
|
38
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# @todo Recurursion protection on deep comparision or one-level comparision |
11
|
|
|
|
|
|
|
sub dispatch |
12
|
|
|
|
|
|
|
{ |
13
|
157
|
|
|
157
|
0
|
163
|
my( $self, $arg1, $arg2) = @_; |
14
|
157
|
|
|
|
|
168
|
my ($arg1_type, $arg2_type) = (ref $arg1, ref $arg2); |
15
|
157
|
|
|
|
|
146
|
my $result = 0; |
16
|
|
|
|
|
|
|
|
17
|
157
|
100
|
66
|
|
|
1570
|
if( |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
33
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
100
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
18
|
|
|
|
|
|
|
not defined $arg1 and defined $arg2 |
19
|
|
|
|
|
|
|
or not defined $arg2 and defined $arg1 |
20
|
|
|
|
|
|
|
) |
21
|
|
|
|
|
|
|
{ |
22
|
12
|
|
|
|
|
12
|
$result = 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
elsif( not defined $arg1 and not defined $arg2 ) |
25
|
|
|
|
|
|
|
{ |
26
|
2
|
|
|
|
|
3
|
$result = 1; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
elsif( looks_like_number($arg1) and looks_like_number($arg2)) |
29
|
|
|
|
|
|
|
{ |
30
|
93
|
|
|
|
|
108
|
$result = ($arg1 == $arg2); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
elsif( $arg1_type eq 'ARRAY' and $arg2_type eq 'ARRAY' ) |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
0
|
|
|
|
0
|
if( scalar @$arg1 == scalar @$arg2 ) |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
|
|
0
|
$result = 1; |
37
|
0
|
|
|
|
|
0
|
for( my $i = 0; $i < scalar @$arg1; $i++ ) |
38
|
|
|
|
|
|
|
{ |
39
|
0
|
0
|
|
|
|
0
|
if( not dispatch($self, $arg1->[$i], $arg2->[$i] )) |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
|
|
|
|
0
|
$result = 0; |
42
|
0
|
|
|
|
|
0
|
last; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
elsif( $arg1_type eq 'HASH' and $arg2_type eq 'HASH' ) |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
|
|
0
|
my @keys1 = sort keys %$arg1; |
50
|
0
|
|
|
|
|
0
|
my @keys2 = sort keys %$arg2; |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
0
|
if( dispatch( $self, \@keys1, \@keys2 ) ) |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
|
|
0
|
my $result = 1; |
55
|
0
|
|
|
|
|
0
|
foreach my $key (@keys1) |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
0
|
|
|
|
0
|
if( not dispatch($self, $arg1->{$key}, $arg2->{$key} )) |
58
|
|
|
|
|
|
|
{ |
59
|
0
|
|
|
|
|
0
|
$result = 0; |
60
|
0
|
|
|
|
|
0
|
last; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif( UNIVERSAL::can($arg1, 'equal')) |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
|
|
0
|
$result = $arg1->equal($arg2); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif( UNIVERSAL::can($arg2, 'equal')) |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
|
|
|
|
0
|
$result = $arg2->equal($arg1); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else |
74
|
|
|
|
|
|
|
{ |
75
|
50
|
|
|
|
|
65
|
$result = ($arg1 eq $arg2); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
157
|
|
|
|
|
419
|
return $result; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |