File Coverage

t/PerlySense-Document-api-match.t
Criterion Covered Total %
statement 43 46 93.4
branch 1 2 50.0
condition n/a
subroutine 8 8 100.0
pod n/a
total 52 56 92.8


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2 1     1   189980 use strict;
  1         2  
  1         99  
3              
4 1     1   2649 use Test::More tests => 11;
  1         20744  
  1         13  
5 1     1   887 use Test::Exception;
  1         2730  
  1         5  
6              
7              
8 1     1   1198 use lib "../lib";
  1         602  
  1         5  
9              
10 1     1   121412 use_ok("Devel::PerlySense::Document");
  1         395  
  1         3  
  1         2  
  1         10  
11 1     1   315 use_ok("Devel::PerlySense::Document::Api");
  1         84  
  1         1  
  1         2  
  1         6  
12 1     1   387 use_ok("Devel::PerlySense::Document::Location");
  1         140  
  1         2  
  1         1  
  1         8  
13              
14              
15 1 50   1   2251 BEGIN { -d "t" and chdir("t"); }
16              
17              
18              
19 1         206 ok(my $oDocument = Devel::PerlySense::Document->new(oPerlySense => Devel::PerlySense->new()), "new ok");
20              
21 1         195 my $dirData = "data/project-lib";
22 1         4 my $fileOrigin = "$dirData/Game/Lawn.pm";
23 1         1 my $nameModule = "Game::Lawn";
24              
25 1         3 my ($object, $method, $oNodeSub);
26 0         0 my (@aMethod);
27 0         0 my $oApi;
28 0         0 my $oLocation;
29 1         5 my $rexFile = qr/.Game.Lawn.pm$/;
30              
31              
32 1         40 my @aAll = qw/
33             END
34             width
35             height
36             rhGrid
37             oUI
38             oController
39             rhPrize
40             new
41             oPlaceWorm
42             oPlacePrize
43             prizeWasClaimedBy
44             placeObjectAt
45             objectHasMoved
46             removeObject
47             isObjectAt
48             isAnythingAt
49             isAnythingBlockingAt
50             oLocationRandom
51             isLocationOnLawn
52             isLocationValidForMove
53             isLocationValidForPlacement
54             isObjectLocationValidForPlacement
55             oDirectionToPrize
56             placeObjectBodyPartAt
57             removeObjectBodyPartAt
58             wormHasCrashed
59             oLocation
60             oLawn
61             raBodyLocation
62             raBodyChar
63             isBlocking
64             color
65             buildBodyRight
66             /;
67              
68 1         11 print "\n* No inheritance\n";
69              
70 1         13 ok($oDocument->parse(file => $fileOrigin), "Parsed file ok");
71              
72 1         338 ok($oDocument->determineLikelyApi(nameModule => $nameModule), " determineLikelyApi ok");
73              
74 1         981 is($oDocument->scoreInterfaceMatch(
75             nameModule => $nameModule,
76             raMethodRequired => [qw/ fksdjf_missing_sdkfjs /],
77             raMethodNice => [qw/ isLocationValidForMove /]),
78             0, " Correct scoreInterfaceMatch for missing required");
79              
80              
81 1         454 cmp_ok($oDocument->scoreInterfaceMatch(
82             nameModule => $nameModule,
83             raMethodRequired => [qw/ isAnythingAt /],
84             raMethodNice => [qw/ /]),
85             '==', 83.84, " Correct scoreInterfaceMatch for one present required");
86              
87              
88 1         431 cmp_ok($oDocument->scoreInterfaceMatch(
89             nameModule => $nameModule,
90             raMethodRequired => [qw/ isAnythingAt wormHasCrashed /],
91             raMethodNice => [qw/ /]),
92             '==', 84.34, " Correct scoreInterfaceMatch for two present required");
93              
94 1         1071 cmp_ok(int($oDocument->scoreInterfaceMatch(
95             nameModule => $nameModule,
96             raMethodRequired => [qw/ isAnythingAt wormHasCrashed /],
97             raMethodNice => [qw/ missing_method /])),
98             '==', 56.00, " Correct scoreInterfaceMatch for two present required");
99              
100              
101 1         767 cmp_ok(int($oDocument->scoreInterfaceMatch(
102             nameModule => $nameModule,
103             raMethodRequired => [qw/ isAnythingAt /],
104             raMethodNice => \@aAll)),
105             '==', 100.00, " Correct scoreInterfaceMatch for full score, all present and all supported");
106              
107              
108              
109              
110              
111             __END__
112              
113              
114