|  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.006';  | 
| 
5
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
 
 | 
307191
 | 
 use strict;  | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
283
 | 
    | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
968
 | 
    | 
| 
6
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
 
 | 
172
 | 
 use warnings;  | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
    | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
828
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
 
 | 
18891
 | 
 use Test::More;  | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2014744
 | 
    | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
290
 | 
    | 
| 
9
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
 
 | 
32216
 | 
 use Data::Dumper;  | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
239079
 | 
    | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2325
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
 
 | 
24894
 | 
 use Guacamole;  | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
208
 | 
    | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6782
 | 
    | 
| 
12
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
 
 | 
27944
 | 
 use Guacamole::Dumper qw/dump_tree/;  | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
105
 | 
    | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2290
 | 
    | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
14
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
 
 | 
644
 | 
 use Exporter "import";  | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
71
 | 
    | 
| 
 
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11958
 | 
    | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our @EXPORT = qw(  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     parses  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     parses_as  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     parsent  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     done_testing  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 );  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub parses {  | 
| 
24
 | 
765
 | 
 
 | 
 
 | 
  
765
  
 | 
  
0
  
 | 
19753
 | 
     my ($text) = @_;  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
26
 | 
765
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2471
 | 
     local $Test::Builder::Level = $Test::Builder::Level + 1;  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
28
 | 
765
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1674
 | 
     my @trees;  | 
| 
29
 | 
765
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4323
 | 
     eval { @trees = Guacamole->parse($text); }  | 
| 
30
 | 
765
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
1833
 | 
     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
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10704
 | 
     is( scalar(@trees), 1, "'$text': parsed unambiguously" );  | 
| 
38
 | 
765
 | 
 
 | 
 
 | 
 
 | 
 
 | 
987126
 | 
     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
  
 | 
3049
 | 
     my ($text) = @_;  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
60
 | 
125
 | 
 
 | 
 
 | 
 
 | 
 
 | 
372
 | 
     local $Test::Builder::Level = $Test::Builder::Level + 1;  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
62
 | 
125
 | 
 
 | 
 
 | 
 
 | 
 
 | 
254
 | 
     my @trees;  | 
| 
63
 | 
125
 | 
 
 | 
 
 | 
 
 | 
 
 | 
254
 | 
     my $res = eval {  | 
| 
64
 | 
125
 | 
 
 | 
 
 | 
 
 | 
 
 | 
654
 | 
         @trees = Guacamole->parse($text);  | 
| 
65
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
         1;  | 
| 
66
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     };  | 
| 
67
 | 
125
 | 
 
 | 
 
 | 
 
 | 
 
 | 
664
 | 
     my $err = $@;  | 
| 
68
 | 
125
 | 
 
 | 
  
 66
  
 | 
 
 | 
 
 | 
1775
 | 
     ok( !defined $res && defined $err, "'$text': did not parse" );  | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
70
 | 
125
 | 
 
 | 
 
 | 
 
 | 
 
 | 
63197
 | 
     foreach my $tree (@trees) {  | 
| 
71
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
         diag( dump_tree($tree) );  | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |