File Coverage

t/PerlySense-Document-api-visible.t
Criterion Covered Total %
statement 76 79 96.2
branch 2 4 50.0
condition n/a
subroutine 12 12 100.0
pod n/a
total 90 95 94.7


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2 1     1   156895 use strict;
  1         2  
  1         68  
3              
4 1     1   525 use Test::More tests => 25;
  1         34934  
  1         8  
5 1     1   1990 use Test::Exception;
  1         13877  
  1         6  
6              
7 1     1   323 use File::Basename;
  1         1  
  1         114  
8 1     1   758 use Data::Dumper;
  1         6128  
  1         70  
9              
10 1     1   384 use lib "../lib";
  1         836  
  1         4  
11              
12 1     1   112229 use_ok("Devel::PerlySense::Document");
  1         737  
  1         3  
  1         3  
  1         13  
13 1     1   1262 use_ok("Devel::PerlySense::Document::Api");
  1         128  
  1         2  
  1         1  
  1         9  
14 1     1   478 use_ok("Devel::PerlySense::Document::Location");
  1         58  
  1         1  
  1         2  
  1         5  
15              
16              
17 1 50   1   254 BEGIN { -d "t" and chdir("t"); }
18              
19              
20             {
21            
22 1         417 my $dirData = "data/project-lib";
  1         5  
23 1         3 my $fileOrigin = "$dirData/Game/Object/WormVisible.pm";
24 1         2 my $nameModule = "Game::Object::WormVisible";
25              
26 1         3 my ($object, $method, $oNodeSub);
27 0         0 my (@aMethod);
28 0         0 my $oApi;
29 0         0 my $oLocation;
30 1         5 my $rexFileWorm = qr/.Game.Object.WormVisible.pm$/;
31 1         4 my $rexFileObject = qr/.Game.ObjectVisible.pm$/;
32 1         3 my $rexFileTable = qr/.Writer.TableVisible.pm$/;
33              
34 1         2 my $dirCpanFake = "data/simple-lib/lib";
35              
36             #So that Win32::Word::Writer::TableVisible can be found outside of the project
37 1         2 local @INC;
38 1         2 push(@INC, $dirCpanFake);
39              
40             #Limit what the project is
41 1     1   4 no warnings;
  1         1  
  1         3501  
42             local *Devel::PerlySense::Project::dirProject = sub {
43 25     25   162 $dirData;
44 1         5 };
45              
46              
47 1         10 my $oPs = Devel::PerlySense->new();
48 1         8 ok(my $oDocument = Devel::PerlySense::Document->new(oPerlySense => $oPs), "new ok");
49              
50              
51 1         795 print "\n* MI inheritance, one project ancestor, one CPAN ancestor\n";
52              
53 1         5 ok($oDocument->parse(file => $fileOrigin), "Parsed file ok");
54              
55 1         703 ok($oDocument->determineLikelyApi("nameModule", $nameModule), " determineLikelyApi ok");
56 1 50       353 is(scalar(keys %{$oDocument->rhPackageApiLikely}), 1, " rhPackageApiLikely key count ok")
  1         29  
57             or die(Dumper($oDocument->rhPackageApiLikely));
58 1         217 ok($oApi = $oDocument->rhPackageApiLikely->{$nameModule}, " Got Game::Object::WormVisible API");
59              
60 1         187 is_deeply([sort keys %{$oApi->rhSub}],
  1         26  
61             [sort qw/
62             isRealPlayer
63             oDirection
64             oEventMove
65             score
66             lengthIdeal
67             lengthActual
68              
69             oLocation
70             oLawn
71             raBodyLocation
72             raBodyChar
73             isBlocking
74             color
75              
76             moveForward
77             oValidLocationAfterMove
78             turn
79             grow
80             crash
81             checkTick
82             awardScorePoints
83             loadFile
84              
85             new
86             _buildBodyRight
87              
88             init
89             ColumnBegin
90             createdColumnCount
91             columnPos
92             alreadyCreatedRow
93             oWriter
94             _privateTableMethod
95              
96             /],
97             " API raSub ok");
98              
99 1         704 ok($oLocation = $oApi->rhSub->{_buildBodyRight}, " Got location for _buildBodyRight");
100 1         843 like($oLocation->file, $rexFileObject, " Correct file name");
101 1         478 is($oLocation->row, 153, " row");
102 1         504 is($oLocation->col, 1, " col");
103 1         1067 is($oLocation->rhProperty->{sub}, "_buildBodyRight", " rhProperty->sub");
104              
105 1         232 ok($oLocation = $oApi->rhSub->{new}, " Got location for new");
106 1         215 like($oLocation->file, $rexFileWorm, " Correct file name");
107 1         210 is($oLocation->row, 142, " row");
108 1         217 is($oLocation->col, 1, " col");
109 1         215 is($oLocation->rhProperty->{sub}, "new", " rhProperty->sub");
110              
111 1         209 ok($oLocation = $oApi->rhSub->{_privateTableMethod}, " Got location for _privateTableMethod");
112 1         212 like($oLocation->file, $rexFileTable, " Correct file name");
113 1         211 is($oLocation->row, 122, " row");
114 1         210 is($oLocation->col, 1, " col");
115 1         220 is($oLocation->rhProperty->{sub}, "_privateTableMethod", " rhProperty->sub");
116              
117 1         187 is_deeply(
118             [sort $oApi->aNameSubVisible(
119             oPerlySense => $oPs,
120             fileCurrent => $fileOrigin,
121             )],
122             [sort qw/
123             isRealPlayer
124             oDirection
125             oEventMove
126             score
127             lengthIdeal
128             lengthActual
129              
130             oLocation
131             oLawn
132             raBodyLocation
133             raBodyChar
134             isBlocking
135             color
136              
137             moveForward
138             oValidLocationAfterMove
139             turn
140             grow
141             crash
142             checkTick
143             awardScorePoints
144             loadFile
145              
146             new
147             _buildBodyRight
148              
149             init
150             ColumnBegin
151             createdColumnCount
152             columnPos
153             alreadyCreatedRow
154             oWriter
155             /],
156             " API aNameSubVisible ok");
157            
158            
159             #print Dumper($oLocation);
160             #print Dumper([ sort keys %{$oApi->rhSub} ]);
161              
162             }
163              
164              
165              
166              
167              
168             __END__