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.008'; |
5
|
38
|
|
|
38
|
|
243000
|
use strict; |
|
38
|
|
|
|
|
253
|
|
|
38
|
|
|
|
|
946
|
|
6
|
38
|
|
|
38
|
|
173
|
use warnings; |
|
38
|
|
|
|
|
58
|
|
|
38
|
|
|
|
|
855
|
|
7
|
|
|
|
|
|
|
|
8
|
38
|
|
|
38
|
|
17553
|
use Test::More; |
|
38
|
|
|
|
|
1893759
|
|
|
38
|
|
|
|
|
282
|
|
9
|
38
|
|
|
38
|
|
31605
|
use Data::Dumper; |
|
38
|
|
|
|
|
223875
|
|
|
38
|
|
|
|
|
2557
|
|
10
|
|
|
|
|
|
|
|
11
|
38
|
|
|
38
|
|
23333
|
use Guacamole; |
|
38
|
|
|
|
|
133
|
|
|
38
|
|
|
|
|
1360
|
|
12
|
38
|
|
|
38
|
|
15364
|
use Guacamole::Dumper qw/dump_tree/; |
|
38
|
|
|
|
|
98
|
|
|
38
|
|
|
|
|
1903
|
|
13
|
|
|
|
|
|
|
|
14
|
38
|
|
|
38
|
|
225
|
use Exporter "import"; |
|
38
|
|
|
|
|
69
|
|
|
38
|
|
|
|
|
13379
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw( |
17
|
|
|
|
|
|
|
parses |
18
|
|
|
|
|
|
|
parses_as |
19
|
|
|
|
|
|
|
parsent |
20
|
|
|
|
|
|
|
done_testing |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub parses { |
24
|
791
|
|
|
791
|
0
|
19609
|
my ($text) = @_; |
25
|
|
|
|
|
|
|
|
26
|
791
|
|
|
|
|
2134
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
27
|
|
|
|
|
|
|
|
28
|
791
|
|
|
|
|
1544
|
my @trees; |
29
|
791
|
|
|
|
|
4082
|
eval { @trees = Guacamole->parse($text); } |
30
|
791
|
100
|
|
|
|
1539
|
or do { diag($@); }; |
|
2
|
|
|
|
|
9
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# debugging |
33
|
791
|
|
|
|
|
3647
|
if (0) { |
34
|
|
|
|
|
|
|
require DDP; |
35
|
|
|
|
|
|
|
my @dumped_trees = map dump_tree($_), @trees; |
36
|
|
|
|
|
|
|
&DDP::p([@dumped_trees]); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
791
|
|
|
|
|
7864
|
is( scalar(@trees), 1, "'$text': parsed unambiguously" ); |
40
|
791
|
|
|
|
|
906064
|
return \@trees; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub parses_as { |
44
|
0
|
|
|
0
|
0
|
0
|
my ( $text, $user_trees ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
my $trees = parses($text); |
49
|
0
|
|
|
|
|
0
|
my @dumped_trees = map dump_tree($_), @{$trees}; |
|
0
|
|
|
|
|
0
|
|
50
|
0
|
|
|
|
|
0
|
my @dumped_user_trees = map dump_tree($_), @{$user_trees}; |
|
0
|
|
|
|
|
0
|
|
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
is_deeply( |
53
|
|
|
|
|
|
|
\@dumped_user_trees, |
54
|
|
|
|
|
|
|
\@dumped_trees, |
55
|
|
|
|
|
|
|
"'$text': parsed exactly as expected", |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub parsent { |
60
|
126
|
|
|
126
|
0
|
2700
|
my ($text) = @_; |
61
|
|
|
|
|
|
|
|
62
|
126
|
|
|
|
|
308
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
63
|
|
|
|
|
|
|
|
64
|
126
|
|
|
|
|
214
|
my @trees; |
65
|
126
|
|
|
|
|
253
|
my $res = eval { |
66
|
126
|
|
|
|
|
542
|
@trees = Guacamole->parse($text); |
67
|
2
|
|
|
|
|
6
|
1; |
68
|
|
|
|
|
|
|
}; |
69
|
126
|
|
|
|
|
574
|
my $err = $@; |
70
|
126
|
|
66
|
|
|
1382
|
ok( !defined $res && defined $err, "'$text': did not parse" ); |
71
|
|
|
|
|
|
|
|
72
|
126
|
|
|
|
|
52310
|
foreach my $tree (@trees) { |
73
|
2
|
|
|
|
|
13
|
diag( dump_tree($tree) ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |