line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
package Test::Deep::This; |
3
|
|
|
|
|
|
|
BEGIN { |
4
|
1
|
|
|
1
|
|
57210
|
$Test::Deep::This::VERSION = '1.00'; |
5
|
|
|
|
|
|
|
} |
6
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
6
|
use base qw(Exporter); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
153
|
|
8
|
|
|
|
|
|
|
our @EXPORT = (qw/this/); |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1203
|
use Data::Dumper; |
|
1
|
|
|
|
|
8593
|
|
|
1
|
|
|
|
|
79
|
|
11
|
1
|
|
|
1
|
|
10
|
use Test::Deep; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
293
|
|
12
|
1
|
|
|
1
|
|
6
|
use base qw(Test::Deep::Cmp); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
19
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub this() { |
16
|
9
|
|
|
9
|
0
|
103
|
return __PACKAGE__->new({ code => sub { $_[0] }, msg => "<>" }); |
|
9
|
|
|
9
|
|
11674
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init { |
20
|
31
|
|
|
31
|
0
|
414
|
my $self = shift; |
21
|
31
|
|
|
|
|
37
|
my ($data) = @_; |
22
|
|
|
|
|
|
|
|
23
|
31
|
|
|
|
|
292
|
$self->{$_} = $data->{$_} for keys %$data; |
24
|
31
|
|
|
|
|
76
|
return $self; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub descend { |
29
|
7
|
|
|
7
|
0
|
51726
|
my $self = shift; |
30
|
7
|
|
|
|
|
16
|
my ($val) = @_; |
31
|
|
|
|
|
|
|
|
32
|
7
|
|
|
|
|
27
|
return $self->{code}->($val); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub renderExp { |
36
|
1
|
|
|
1
|
0
|
410
|
my $self = shift; |
37
|
1
|
|
|
|
|
5
|
return "$self"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _dump { |
41
|
8
|
|
|
8
|
|
52
|
my $dumper = Data::Dumper->new([@_]); |
42
|
8
|
|
|
|
|
253
|
$dumper->Terse(1)->Indent(0); |
43
|
8
|
|
|
|
|
157
|
return $dumper->Dump; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _upgrade { |
47
|
20
|
|
|
20
|
|
25
|
my $self = shift; |
48
|
20
|
100
|
|
|
|
63
|
return $self if ref $self eq 'Test::Deep::This'; |
49
|
|
|
|
|
|
|
return __PACKAGE__->new({ |
50
|
8
|
|
|
8
|
|
166
|
code => sub { return $self }, |
51
|
8
|
|
|
|
|
43
|
msg => _dump($self), |
52
|
|
|
|
|
|
|
}); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _operator1 { |
56
|
9
|
|
|
9
|
|
13
|
my ($op) = @_; |
57
|
9
|
|
|
|
|
469
|
return eval "sub { $op(\$_[0]) }"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _operator2 { |
61
|
24
|
|
|
24
|
|
28
|
my ($op) = @_; |
62
|
24
|
|
|
|
|
1310
|
return eval "sub { \$_[0] $op \$_[1] }"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
1
|
|
2107
|
use overload '""' => sub { $_[0]->{msg} }; |
|
1
|
|
|
25
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
|
25
|
|
|
|
|
143
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use overload |
68
|
24
|
|
|
|
|
33
|
map { |
69
|
1
|
|
|
|
|
4
|
my $op = $_; |
70
|
24
|
|
|
|
|
50
|
my $operator = _operator2($op); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$op => sub { |
73
|
10
|
|
|
10
|
|
58
|
my ($left, $right, $reorder) = @_; |
74
|
10
|
100
|
|
|
|
36
|
($left, $right) = ($right, $left) if $reorder; |
75
|
10
|
|
|
|
|
25
|
$left = _upgrade($left); |
76
|
10
|
|
|
|
|
26
|
$right = _upgrade($right); |
77
|
|
|
|
|
|
|
return __PACKAGE__->new({ |
78
|
|
|
|
|
|
|
code => sub { |
79
|
10
|
|
|
10
|
|
18
|
my $val = shift; |
80
|
10
|
|
|
|
|
33
|
$operator->($left->{code}->($val), $right->{code}->($val)); |
81
|
|
|
|
|
|
|
}, |
82
|
|
|
|
|
|
|
# overload("") returns a string representation of a predicate |
83
|
|
|
|
|
|
|
# but overload(.) generates a delayed operator '.' |
84
|
10
|
|
|
|
|
74
|
msg => "("."$left".") $op ("."$right".")", #FIXME: track operator priorities and omit braces where possible |
85
|
|
|
|
|
|
|
}); |
86
|
|
|
|
|
|
|
} |
87
|
1
|
|
|
1
|
|
283
|
} qw(> < >= <= == != <=> lt gt le ge eq ne cmp), qw(+ - * / % ** << >> x .); |
|
1
|
|
|
|
|
2
|
|
|
24
|
|
|
|
|
142
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
use overload |
90
|
9
|
|
|
|
|
16
|
map { |
91
|
1
|
|
|
|
|
2
|
my $op = $_; |
92
|
9
|
|
|
|
|
13
|
my $operator = _operator1($op); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$op => sub { |
95
|
4
|
|
|
4
|
|
25
|
my ($arg) = @_; |
96
|
|
|
|
|
|
|
return __PACKAGE__->new({ |
97
|
|
|
|
|
|
|
code => sub { |
98
|
4
|
|
|
4
|
|
10
|
my $val = shift; |
99
|
4
|
|
|
|
|
19
|
$operator->($arg->{code}->($val)); |
100
|
|
|
|
|
|
|
}, |
101
|
4
|
|
|
|
|
27
|
msg => "$op ("."$arg".")", |
102
|
|
|
|
|
|
|
}); |
103
|
|
|
|
|
|
|
} |
104
|
1
|
|
|
1
|
|
433
|
} qw(! neg atan2 cos sin exp abs log sqrt); |
|
1
|
|
|
|
|
1
|
|
|
9
|
|
|
|
|
48
|
|
105
|
|
|
|
|
|
|
|
106
|
1
|
|
|
1
|
|
133
|
use overload 'fallback' => 0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |