line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Expr; |
2
|
|
|
|
|
|
|
our $VERSION = '0.000006'; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
73676
|
use 5.012; use warnings; |
|
2
|
|
|
2
|
|
14
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
56
|
|
5
|
2
|
|
|
2
|
|
1862
|
use Keyword::Declare; |
|
2
|
|
|
|
|
259943
|
|
|
2
|
|
|
|
|
22
|
|
6
|
2
|
|
|
2
|
|
1856
|
use Data::Dump; |
|
2
|
|
|
|
|
10378
|
|
|
2
|
|
|
|
|
154
|
|
7
|
2
|
|
|
2
|
|
18
|
use List::Util 'max'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
122
|
|
8
|
2
|
|
|
2
|
|
622
|
use Test::More; |
|
2
|
|
|
|
|
63703
|
|
|
2
|
|
|
|
|
19
|
|
9
|
2
|
|
|
2
|
|
1491
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
601
|
|
|
2
|
|
|
|
|
14
|
|
10
|
|
|
|
|
|
|
our @EXPORT = @Test::More::EXPORT; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _trim { |
13
|
6
|
|
|
6
|
|
23
|
my $str = shift; |
14
|
6
|
|
|
|
|
39
|
$str =~ s{\A\s*|\s*\Z}{}g; |
15
|
6
|
|
|
|
|
21
|
return $str; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $PERL_VAR = qr{ ((?&PerlVariable)) $PPR::GRAMMAR }xms; |
19
|
|
|
|
|
|
|
my $PERL_LITERAL = qr{^ (?> (?&PerlString) |
20
|
|
|
|
|
|
|
| (?&PerlQuotelikeQR) |
21
|
|
|
|
|
|
|
| (?&PerlQuotelikeQW) |
22
|
|
|
|
|
|
|
| (?&PerlNumber) ) $ $PPR::GRAMMAR }xms; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
sub import { |
25
|
2
|
|
|
2
|
|
50
|
my ($package) = @_; |
26
|
2
|
|
|
|
|
563
|
$package->export_to_level(1, @_); |
27
|
2
|
|
|
|
|
6
|
|
28
|
0
|
50
|
50
|
2
|
|
0
|
keyword ok (Expr $test) {{{ |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
45
|
|
|
2
|
|
|
|
|
252337
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
4
|
|
29
|
0
|
|
|
|
|
0
|
ok do{«$test»}, q{«$test»}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
15
|
|
30
|
2
|
|
|
|
|
17
|
}}} |
|
2
|
|
|
|
|
18
|
|
31
|
2
|
|
|
|
|
110
|
|
|
2
|
|
|
|
|
53
|
|
32
|
2
|
50
|
50
|
2
|
|
76166
|
keyword ok (ListElem $test, Comma, ListElem $desc) { |
|
0
|
|
|
3
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
24
|
|
|
3
|
|
|
|
|
399758
|
|
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
7
|
|
33
|
2
|
|
|
|
|
9
|
# Work out what values to report if there's a problem... |
34
|
0
|
|
|
|
|
0
|
(my $test_code = $test) =~ s/^\s*do\s*\{(.*)\}\s*$/$1/; |
|
3
|
|
|
|
|
25
|
|
35
|
0
|
|
|
|
|
0
|
my ($lhs, $op, $rhs) |
|
3
|
|
|
|
|
28
|
|
36
|
|
|
|
|
|
|
= $test_code =~ m{(.*?) |
37
|
|
|
|
|
|
|
(<|(?!<-)>|<=|>=|==|!=|<=>|~~|\b(?:lt|gt|le|ge|eq|ne|cmp)\b) |
38
|
|
|
|
|
|
|
(.*) |
39
|
|
|
|
|
|
|
}xms; |
40
|
0
|
|
|
|
|
0
|
my $test_setup; |
|
3
|
|
|
|
|
10
|
|
41
|
|
|
|
|
|
|
my $test_expr; |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
0
|
if ($op) { |
|
3
|
100
|
|
|
|
13
|
|
44
|
0
|
|
|
|
|
0
|
$test_setup = qq{my \$lhs = $lhs; my \$rhs = $rhs;}; |
|
2
|
|
|
|
|
10
|
|
45
|
0
|
|
|
|
|
0
|
$test_expr = '$lhs '.$op.' $rhs'; |
|
2
|
|
|
|
|
8
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else { |
48
|
0
|
|
|
|
|
0
|
$lhs = $test_code; |
|
1
|
|
|
|
|
3
|
|
49
|
0
|
|
|
|
|
0
|
$rhs = ""; |
|
1
|
|
|
|
|
3
|
|
50
|
0
|
|
|
|
|
0
|
$test_setup = qq{my \$lhs = $lhs;}; |
|
1
|
|
|
|
|
6
|
|
51
|
0
|
|
|
|
|
0
|
$test_expr = q{$lhs}; |
|
1
|
|
|
|
|
2
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
my @vars = grep {defined} $test =~ m{$PERL_VAR}g; |
|
0
|
|
|
|
|
0
|
|
|
3
|
|
|
|
|
214
|
|
|
0
|
|
|
|
|
0
|
|
55
|
0
|
|
|
|
|
0
|
($lhs, $rhs, @vars) = map {_trim $_} $lhs, $rhs, @vars; |
|
0
|
|
|
|
|
0
|
|
|
3
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
20
|
|
56
|
0
|
|
|
|
|
0
|
my $var_len = max map {length} $lhs, $rhs, @vars; |
|
0
|
|
|
|
|
0
|
|
|
3
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
26
|
|
57
|
0
|
|
|
|
|
0
|
my %seen = ( $rhs => 1, $lhs => 1 ); |
|
3
|
|
|
|
|
16
|
|
58
|
|
|
|
|
|
|
my @diagnostics = ( |
59
|
|
|
|
|
|
|
( $lhs !~ $PERL_LITERAL |
60
|
|
|
|
|
|
|
? qq{diag sprintf(q{ %${var_len}s --> }, '$lhs'), Data::Dump::dump(\$lhs);} |
61
|
|
|
|
|
|
|
: () |
62
|
|
|
|
|
|
|
), |
63
|
|
|
|
|
|
|
( $rhs && $rhs !~ $PERL_LITERAL |
64
|
|
|
|
|
|
|
? qq{diag sprintf(q{ %${var_len}s --> }, '$rhs'), Data::Dump::dump(\$rhs);} |
65
|
|
|
|
|
|
|
: () |
66
|
|
|
|
|
|
|
), |
67
|
0
|
|
|
|
|
0
|
map {qq{diag sprintf(q{ %${var_len}s --> }, q{$_}), Data::Dump::dump($_);}} |
|
0
|
|
|
|
|
0
|
|
68
|
0
|
0
|
0
|
|
|
0
|
grep { !$seen{$_}++ } |
|
0
|
0
|
66
|
|
|
0
|
|
|
3
|
50
|
|
|
|
112
|
|
|
0
|
50
|
|
|
|
0
|
|
69
|
|
|
|
|
|
|
@vars |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
0
|
unshift @diagnostics, qq{diag q{ because:};} |
|
3
|
50
|
|
|
|
11
|
|
73
|
|
|
|
|
|
|
if @diagnostics; |
74
|
0
|
0
|
0
|
|
|
0
|
unshift @diagnostics, qq{diag q{}; diag q{ ($test_code) was false};} |
|
3
|
100
|
50
|
|
|
335
|
|
75
|
|
|
|
|
|
|
if (eval($desc)//'') ne qq{$test_code}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Build the test code... |
78
|
0
|
|
|
|
|
0
|
qq{ |
|
3
|
|
|
|
|
46
|
|
79
|
|
|
|
|
|
|
{ |
80
|
|
|
|
|
|
|
$test_setup |
81
|
|
|
|
|
|
|
if ($test_expr) { |
82
|
|
|
|
|
|
|
Test::More::ok(1, $desc); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
|
|
|
|
|
|
fail($desc); @diagnostics diag q{}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
}; |
89
|
2
|
|
|
|
|
20
|
} |
|
2
|
|
|
|
|
17
|
|
90
|
2
|
|
|
|
|
95
|
} |
91
|
2
|
|
|
2
|
|
108095
|
|
92
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
93
|
|
|
|
|
|
|
__END__ |