File Coverage

t/PerlySense-Document-api-likely.t
Criterion Covered Total %
statement 90 96 93.7
branch 1 2 50.0
condition n/a
subroutine 10 10 100.0
pod n/a
total 101 108 93.5


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2 1     1   118464 use strict;
  1         2  
  1         83  
3              
4 1     1   596 use Test::More tests => 40;
  1         15099  
  1         7  
5 1     1   640 use Test::Exception;
  1         2498  
  1         4  
6              
7 1     1   211 use File::Basename;
  1         1  
  1         107  
8 1     1   991 use Data::Dumper;
  1         7280  
  1         75  
9              
10 1     1   373 use lib "../lib";
  1         544  
  1         3  
11              
12 1     1   82093 use_ok("Devel::PerlySense::Document");
  1         471  
  1         3  
  1         1  
  1         12  
13 1     1   1471 use_ok("Devel::PerlySense::Document::Api");
  1         110  
  1         2  
  1         1  
  1         8  
14 1     1   629 use_ok("Devel::PerlySense::Document::Location");
  1         72  
  1         2  
  1         1  
  1         6  
15              
16              
17 1 50   1   2024 BEGIN { -d "t" and chdir("t"); }
18              
19              
20             {
21              
22 1         396 ok(my $oDocument = Devel::PerlySense::Document->new(oPerlySense => Devel::PerlySense->new()), "new ok");
  1         7  
23              
24 1         1779 my $dirData = "data/project-lib";
25 1         3 my $fileOrigin = "$dirData/Game/Lawn.pm";
26 1         3 my $nameModule = "Game::Lawn";
27              
28 1         1 my ($object, $method, $oNodeSub);
29 0         0 my (@aMethod);
30 0         0 my $oApi;
31 0         0 my $oLocation;
32 1         5 my $rexFile = qr/.Game.Lawn.pm$/;
33              
34              
35              
36 1         12 print "\n* No inheritance\n";
37              
38 1         6 ok($oDocument->parse(file => $fileOrigin), "Parsed file ok");
39              
40 1         339 ok($oDocument->determineLikelyApi(nameModule => $nameModule), " determineLikelyApi ok");
41 1         300 is(scalar(keys %{$oDocument->rhPackageApiLikely}), 1, " rhPackageApiLikely key count ok");
  1         27  
42 1         217 ok($oApi = $oDocument->rhPackageApiLikely->{"Game::Lawn"}, " Got Game::Lawn API");
43             #warn(Dumper($oApi->rhSub));
44 1         190 is_deeply([sort keys %{$oApi->rhSub}],
  1         25  
45             [sort qw/
46             END
47             width
48             buildBodyRight
49             color
50             oLocation
51             oLawn
52             raBodyLocation
53             raBodyChar
54             isBlocking
55             height
56             rhGrid
57             oUI
58             oController
59             rhPrize
60             new
61             oPlaceWorm
62             oPlacePrize
63             prizeWasClaimedBy
64             placeObjectAt
65             objectHasMoved
66             removeObject
67             isObjectAt
68             isAnythingAt
69             isAnythingBlockingAt
70             oLocationRandom
71             isLocationOnLawn
72             isLocationValidForMove
73             isLocationValidForPlacement
74             isObjectLocationValidForPlacement
75             oDirectionToPrize
76             placeObjectBodyPartAt
77             removeObjectBodyPartAt
78             wormHasCrashed
79             /],
80             " API raSub ok");
81              
82 1         671 ok($oLocation = $oApi->rhSub->{width}, " Got location");
83 1         213 like($oLocation->file, $rexFile, " Correct file name");
84 1         430 is($oLocation->row, 0, " row");
85 1         217 is($oLocation->col, 0, " row");
86 1         215 is($oLocation->rhProperty->{sub}, "width", " rhProperty->sub");
87              
88 1         215 ok($oLocation = $oApi->rhSub->{removeObject}, " Got location");
89 1         216 like($oLocation->file, $rexFile, " Correct file name");
90 1         214 is($oLocation->row, 280, " row");
91 1         213 is($oLocation->col, 1, " row");
92 1         213 is($oLocation->rhProperty->{sub}, "removeObject", " rhProperty->sub");
93              
94              
95             #print Dumper($oLocation);
96             #print Dumper([ sort keys %{$oApi->rhSub} ]);
97              
98             }
99              
100              
101              
102              
103              
104             {
105              
106 1         18399 ok(my $oDocument = Devel::PerlySense::Document->new(oPerlySense => Devel::PerlySense->new()), "new ok");
  1         17  
107              
108 1         888 my $dirData = "data/project-lib";
109 1         4 my $fileOrigin = "$dirData/Game/Object/Worm.pm";
110 1         2 my $nameModule = "Game::Object::Worm";
111              
112 1         2 my ($object, $method, $oNodeSub);
113 0         0 my (@aMethod);
114 0         0 my $oApi;
115 0         0 my $oLocation;
116 1         5 my $rexFileWorm = qr/.Game.Object.Worm.pm$/;
117 1         3 my $rexFileObject = qr/.Game.Object.pm$/;
118              
119              
120              
121 1         281 print "\n* Single inheritance, one ancestor\n";
122              
123 1         7 ok($oDocument->parse(file => $fileOrigin), "Parsed file ok");
124              
125 1         337 ok($oDocument->determineLikelyApi("nameModule", $nameModule), " determineLikelyApi ok");
126 1         998 is(scalar(keys %{$oDocument->rhPackageApiLikely}), 1, " rhPackageApiLikely key count ok");
  1         51  
127 1         464 ok($oApi = $oDocument->rhPackageApiLikely->{"Game::Object::Worm"}, " Got Game::Object::Worm API");
128              
129 1         472 is_deeply([sort keys %{$oApi->rhSub}],
  1         31  
130             [sort qw/
131             isRealPlayer
132             oDirection
133             oEventMove
134             score
135             lengthIdeal
136             lengthActual
137              
138             oLocation
139             oLawn
140             raBodyLocation
141             raBodyChar
142             isBlocking
143             color
144              
145             moveForward
146             oValidLocationAfterMove
147             turn
148             grow
149             crash
150             checkTick
151             awardScorePoints
152             loadFile
153              
154             new
155             buildBodyRight
156             /],
157             " API raSub ok");
158              
159 1         615 ok($oLocation = $oApi->rhSub->{oLocation}, " Got location");
160 1         381 like($oLocation->file, $rexFileObject, " Correct file name");
161 1         213 is($oLocation->row, 0, " row");
162 1         212 is($oLocation->col, 0, " row");
163 1         210 is($oLocation->rhProperty->{sub}, "oLocation", " rhProperty->sub");
164              
165 1         216 ok($oLocation = $oApi->rhSub->{buildBodyRight}, " Got location");
166 1         212 like($oLocation->file, $rexFileObject, " Correct file name");
167 1         210 is($oLocation->row, 153, " row");
168 1         209 is($oLocation->col, 1, " row");
169 1         209 is($oLocation->rhProperty->{sub}, "buildBodyRight", " rhProperty->sub");
170              
171 1         209 ok($oLocation = $oApi->rhSub->{new}, " Got location");
172 1         215 like($oLocation->file, $rexFileWorm, " Correct file name");
173 1         384 is($oLocation->row, 142, " row");
174 1         215 is($oLocation->col, 1, " row");
175 1         210 is($oLocation->rhProperty->{sub}, "new", " rhProperty->sub");
176              
177              
178             #print Dumper($oLocation);
179             #print Dumper([ sort keys %{$oApi->rhSub} ]);
180              
181             }
182              
183              
184              
185              
186              
187             #buildBodyRight
188             #new
189              
190              
191             __END__
192              
193              
194