line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Guacamole::Test; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:XSAWYERX'; |
3
|
|
|
|
|
|
|
# ABSTRACT: What Guacamole uses to test itself |
4
|
|
|
|
|
|
|
$Guacamole::Test::VERSION = '0.007'; |
5
|
35
|
|
|
35
|
|
311327
|
use strict; |
|
35
|
|
|
|
|
285
|
|
|
35
|
|
|
|
|
1052
|
|
6
|
35
|
|
|
35
|
|
173
|
use warnings; |
|
35
|
|
|
|
|
67
|
|
|
35
|
|
|
|
|
888
|
|
7
|
|
|
|
|
|
|
|
8
|
35
|
|
|
35
|
|
20072
|
use Test::More; |
|
35
|
|
|
|
|
2088390
|
|
|
35
|
|
|
|
|
301
|
|
9
|
35
|
|
|
35
|
|
33663
|
use Data::Dumper; |
|
35
|
|
|
|
|
246613
|
|
|
35
|
|
|
|
|
2538
|
|
10
|
|
|
|
|
|
|
|
11
|
35
|
|
|
35
|
|
25814
|
use Guacamole; |
|
35
|
|
|
|
|
210
|
|
|
35
|
|
|
|
|
6933
|
|
12
|
35
|
|
|
35
|
|
28344
|
use Guacamole::Dumper qw/dump_tree/; |
|
35
|
|
|
|
|
108
|
|
|
35
|
|
|
|
|
2321
|
|
13
|
|
|
|
|
|
|
|
14
|
35
|
|
|
35
|
|
649
|
use Exporter "import"; |
|
35
|
|
|
|
|
77
|
|
|
35
|
|
|
|
|
12464
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw( |
17
|
|
|
|
|
|
|
parses |
18
|
|
|
|
|
|
|
parses_as |
19
|
|
|
|
|
|
|
parsent |
20
|
|
|
|
|
|
|
done_testing |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub parses { |
24
|
765
|
|
|
765
|
0
|
20343
|
my ($text) = @_; |
25
|
|
|
|
|
|
|
|
26
|
765
|
|
|
|
|
2429
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
27
|
|
|
|
|
|
|
|
28
|
765
|
|
|
|
|
1640
|
my @trees; |
29
|
765
|
|
|
|
|
4385
|
eval { @trees = Guacamole->parse($text); } |
30
|
765
|
100
|
|
|
|
1722
|
or do { diag($@); }; |
|
2
|
|
|
|
|
15
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# debugging |
33
|
|
|
|
|
|
|
# use DDP; |
34
|
|
|
|
|
|
|
# my @dumped_trees = map dump_tree($_), @trees; |
35
|
|
|
|
|
|
|
# p @dumped_trees; |
36
|
|
|
|
|
|
|
|
37
|
765
|
|
|
|
|
11150
|
is( scalar(@trees), 1, "'$text': parsed unambiguously" ); |
38
|
765
|
|
|
|
|
934069
|
return \@trees; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub parses_as { |
42
|
0
|
|
|
0
|
0
|
0
|
my ( $text, $user_trees ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
my $trees = parses($text); |
47
|
0
|
|
|
|
|
0
|
my @dumped_trees = map dump_tree($_), @{$trees}; |
|
0
|
|
|
|
|
0
|
|
48
|
0
|
|
|
|
|
0
|
my @dumped_user_trees = map dump_tree($_), @{$user_trees}; |
|
0
|
|
|
|
|
0
|
|
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
is_deeply( |
51
|
|
|
|
|
|
|
\@dumped_user_trees, |
52
|
|
|
|
|
|
|
\@dumped_trees, |
53
|
|
|
|
|
|
|
"'$text': parsed exactly as expected", |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub parsent { |
58
|
125
|
|
|
125
|
0
|
3073
|
my ($text) = @_; |
59
|
|
|
|
|
|
|
|
60
|
125
|
|
|
|
|
372
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
61
|
|
|
|
|
|
|
|
62
|
125
|
|
|
|
|
268
|
my @trees; |
63
|
125
|
|
|
|
|
254
|
my $res = eval { |
64
|
125
|
|
|
|
|
715
|
@trees = Guacamole->parse($text); |
65
|
4
|
|
|
|
|
15
|
1; |
66
|
|
|
|
|
|
|
}; |
67
|
125
|
|
|
|
|
707
|
my $err = $@; |
68
|
125
|
|
66
|
|
|
1960
|
ok( !defined $res && defined $err, "'$text': did not parse" ); |
69
|
|
|
|
|
|
|
|
70
|
125
|
|
|
|
|
62106
|
foreach my $tree (@trees) { |
71
|
2
|
|
|
|
|
12
|
diag( dump_tree($tree) ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |