Coverage Summary

# File Coverage

t/PerlySense-Document-sub.t
Criterion | Covered | Total | %
--- | --- | --- | ---
statement | 98 | 98 | 100.0
branch | 2 | 4 | 50.0
condition |  |  | n/a
subroutine | 10 | 10 | 100.0
pod |  |  | n/a
total | 110 | 112 | 98.2

line | stmt | bran | cond | sub | pod | time | code
--- | --- | --- | --- | --- | --- | --- | ---
1 |  |  |  |  |  |  | #!/usr/bin/perl -w
2 | 1 |  |  | 1 |  | 163179 | use strict;
| 1 |  |  |  |  | 2 |
| 1 |  |  |  |  | 68 |
3 |  |  |  |  |  |  |
4 | 1 |  |  | 1 |  | 608 | use Test::More tests => 57;
| 1 |  |  |  |  | 17355 |
| 1 |  |  |  |  | 8 |
5 | 1 |  |  | 1 |  | 2892 | use Test::Exception;
| 1 |  |  |  |  | 3197 |
| 1 |  |  |  |  | 4 |
6 |  |  |  |  |  |  |
7 | 1 |  |  | 1 |  | 4780 | use Data::Dumper;
| 1 |  |  |  |  | 23759 |
| 1 |  |  |  |  | 95 |
8 |  |  |  |  |  |  |
9 | 1 |  |  | 1 |  | 13 | use File::Basename;
| 1 |  |  |  |  | 2 |
| 1 |  |  |  |  | 115 |
10 | 1 |  |  | 1 |  | 537 | use File::Spec::Functions;
| 1 |  |  |  |  | 490 |
| 1 |  |  |  |  | 61 |
11 |  |  |  |  |  |  |
12 | 1 |  |  | 1 |  | 270 | use lib "../lib";
| 1 |  |  |  |  | 562 |
| 1 |  |  |  |  | 4 |
13 |  |  |  |  |  |  |
14 | 1 |  |  | 1 |  | 113711 | use_ok("Devel::PerlySense::Document");
| 1 |  |  |  |  | 1122 |
| 1 |  |  |  |  | 4 |
| 1 |  |  |  |  | 1 |
| 1 |  |  |  |  | 10 |
15 | 1 |  |  | 1 |  | 305 | use_ok("Devel::PerlySense::Document::Location");
| 1 |  |  |  |  | 95 |
| 1 |  |  |  |  | 2 |
| 1 |  |  |  |  | 2 |
| 1 |  |  |  |  | 5 |
16 |  |  |  |  |  |  |
17 |  |  |  |  |  |  |
18 | 1 | 50 |  | 1 |  | 7864 | BEGIN { -d "t" and chdir("t"); }
19 |  |  |  |  |  |  |
20 |  |  |  |  |  |  |
21 | 1 |  |  |  |  | 198 | ok(my $oDocument = Devel::PerlySense::Document->new(oPerlySense => Devel::PerlySense->new()), "new ok");
22 |  |  |  |  |  |  |
23 | 1 |  |  |  |  | 189 | my $dirData = "data/simple-lib";
24 | 1 |  |  |  |  | 3 | my $fileOrigin = "$dirData/lib/Win32/Word/Writer.pm";
25 | 1 |  |  |  |  | 1 | my $oLocation;
26 |  |  |  |  |  |  |
27 |  |  |  |  |  |  |
28 |  |  |  |  |  |  |
29 | 1 |  |  |  |  | 5 | note("Find sub by name");
30 |  |  |  |  |  |  |
31 | 1 |  |  |  |  | 54 | ok($oDocument->parse(file => $fileOrigin), "Parsed file ok");
32 | 1 |  |  |  |  | 305 | is(my $package = $oDocument->packageAt(row => 429), "Win32::Word::Writer", "Correct package Table ok");
33 |  |  |  |  |  |  |
34 | 1 |  |  |  |  | 194 | is($oDocument->oLocationSub(name => "Write", package => "missing package"), undef, "Didn't find missing package declaration");
35 | 1 |  |  |  |  | 198 | ok($oLocation = $oDocument->oLocationSub(name => "Write", package => $package), "Found correct declaration");
36 | 1 |  |  |  |  | 388 | is($oLocation->file, $fileOrigin, " Got file");
37 | 1 |  |  |  |  | 221 | is($oLocation->row, 396, " row");
38 | 1 |  |  |  |  | 213 | is($oLocation->col, 1, " col");
39 |  |  |  |  |  |  |
40 | 1 |  |  |  |  | 188 | ok($oLocation = $oDocument->oLocationSub(name => "main_sub"), "Found correct declaration in default package main");
41 | 1 |  |  |  |  | 213 | is($oLocation->file, $fileOrigin, " Got file");
42 | 1 |  |  |  |  | 214 | is($oLocation->row, 132, " row");
43 | 1 |  |  |  |  | 211 | is($oLocation->col, 1, " col");
44 |  |  |  |  |  |  |
45 | 1 |  |  |  |  | 188 | ok($oLocation = $oDocument->oLocationSub(name => "NewParagraph", package => $package), "Found correct declaration");
46 | 1 |  |  |  |  | 213 | is($oLocation->file, $fileOrigin, " Got file");
47 | 1 |  |  |  |  | 2786 | is($oLocation->row, 446, " row");
48 | 1 |  |  |  |  | 261 | is($oLocation->col, 1, " col");
49 |  |  |  |  |  |  |
50 |  |  |  |  |  |  |
51 |  |  |  |  |  |  |
52 |  |  |  |  |  |  |
53 |  |  |  |  |  |  |
54 | 1 |  |  |  |  | 197 | note("Find the sub at row/col");
55 | 1 |  |  |  |  | 63 | $oLocation = $oDocument->oLocationSubAt(row => 2, col => 1);
56 | 1 | 50 |  |  |  | 4 | ok( ! $oLocation, "Missing sub returned undef") or warn(Dumper($oLocation));
57 |  |  |  |  |  |  |
58 | 1 |  |  |  |  | 196 | ok(
59 |  |  |  |  |  |  | ! $oDocument->oLocationSubAt(row => 395, col => 1),
60 |  |  |  |  |  |  | "Missing sub (edge case: just before) returned undef",
61 |  |  |  |  |  |  | );
62 | 1 |  |  |  |  | 189 | ok( $oLocation = $oDocument->oLocationSubAt(row => 396, col => 1), "Found sub on start line");
63 | 1 |  |  |  |  | 224 | is($oLocation->row, 396, " Got correct sub start row");
64 | 1 |  |  |  |  | 212 | is($oLocation->col, 1, " Got correct sub start col");
65 | 1 |  |  |  |  | 210 | is($oLocation->rhProperty->{nameSub}, "Write", " Got correct sub name");
66 | 1 |  |  |  |  | 212 | ok(my $oLocationEnd = $oLocation->rhProperty->{oLocationEnd}, " Got and end oLocation");
67 | 1 |  |  |  |  | 213 | is($oLocationEnd->row, 404, " Got correct sub end row");
68 | 1 |  |  |  |  | 210 | is($oLocationEnd->col, 2, " Got correct sub end col");
69 |  |  |  |  |  |  |
70 | 1 |  |  |  |  | 186 | ok( $oLocation = $oDocument->oLocationSubAt(row => 404, col => 1), "Found sub on end line");
71 | 1 |  |  |  |  | 201 | ok(
72 |  |  |  |  |  |  | ! $oDocument->oLocationSubAt(row => 405, col => 1),
73 |  |  |  |  |  |  | "Missing sub (edge case: just after) returned undef",
74 |  |  |  |  |  |  | );
75 |  |  |  |  |  |  |
76 |  |  |  |  |  |  | #is($oLocation->file
77 |  |  |  |  |  |  |
78 |  |  |  |  |  |  |
79 |  |  |  |  |  |  |
80 |  |  |  |  |  |  |
81 |  |  |  |  |  |  |
82 |  |  |  |  |  |  |
83 |  |  |  |  |  |  |
84 | 1 |  |  |  |  | 191 | ok($oDocument = Devel::PerlySense::Document->new(oPerlySense => Devel::PerlySense->new()), "new ok");
85 | 1 |  |  |  |  | 197 | $fileOrigin = "$dirData/lib/Game/Event/Timed.pm";
86 |  |  |  |  |  |  |
87 | 1 |  |  |  |  | 23033 | ok($oDocument->parse(file => $fileOrigin), "Parsed file ok");
88 | 1 |  |  |  |  | 2260 | ok($oLocation = $oDocument->oLocationSubDefinition(name => "checkTick", row => 107), "Found sub from col package");
89 | 1 |  |  |  |  | 925 | is($oLocation->file, $fileOrigin, " Got file");
90 | 1 |  |  |  |  | 4397 | is($oLocation->row, 123, " row");
91 | 1 |  |  |  |  | 3526 | is($oLocation->col, 1, " col");
92 |  |  |  |  |  |  |
93 |  |  |  |  |  |  |
94 | 1 |  |  |  |  | 422 | ok($oLocation = $oDocument->oLocationSubDefinition(name => "checkTick", row => 1), "Found sub from col package main");
95 | 1 |  |  |  |  | 2163 | is($oLocation->file, $fileOrigin, " Got file");
96 | 1 |  |  |  |  | 803 | is($oLocation->row, 21, " row");
97 | 1 |  |  |  |  | 11194 | is($oLocation->col, 1, " col");
98 |  |  |  |  |  |  |
99 |  |  |  |  |  |  |
100 |  |  |  |  |  |  |
101 | 1 |  |  |  |  | 298 | ok($oLocation = $oDocument->oLocationSubDefinition(name => "checkTick", package => "main"), "Found sub from param package main");
102 | 1 |  |  |  |  | 216 | is($oLocation->file, $fileOrigin, " Got file");
103 | 1 |  |  |  |  | 213 | is($oLocation->row, 21, " row");
104 | 1 |  |  |  |  | 435 | is($oLocation->col, 1, " col");
105 |  |  |  |  |  |  |
106 |  |  |  |  |  |  |
107 | 1 |  |  |  |  | 607 | ok($oLocation = $oDocument->oLocationSubDefinition(name => "checkTick"), "Found sub from default package main");
108 | 1 |  |  |  |  | 2052 | is($oLocation->file, $fileOrigin, " Got file");
109 | 1 |  |  |  |  | 240 | is($oLocation->row, 21, " row");
110 | 1 |  |  |  |  | 208 | is($oLocation->col, 1, " col");
111 |  |  |  |  |  |  |
112 |  |  |  |  |  |  |
113 | 1 |  |  |  |  | 8367 | ok($oLocation = $oDocument->oLocationSubDefinition(name => "checkTick", package => "Game::Event::Timed"), "Found sub from default package main");
114 | 1 |  |  |  |  | 328 | is($oLocation->file, $fileOrigin, " Got file");
115 | 1 |  |  |  |  | 237 | is($oLocation->row, 123, " row");
116 | 1 |  |  |  |  | 234 | is($oLocation->col, 1, " col");
117 |  |  |  |  |  |  |
118 |  |  |  |  |  |  |
119 |  |  |  |  |  |  |
120 |  |  |  |  |  |  |
121 |  |  |  |  |  |  |
122 |  |  |  |  |  |  |
123 | 1 |  |  |  |  | 218 | print "\n*** Parent modules\n";
124 |  |  |  |  |  |  |
125 | 1 |  |  |  |  | 3 | $dirData = "data/project-lib";
126 | 1 |  |  |  |  | 5 | my $rexFileDest = qr/Game.Object.Worm.pm/;
127 |  |  |  |  |  |  |
128 | 1 |  |  |  |  | 10 | ok($oDocument = Devel::PerlySense::Document->new(oPerlySense => Devel::PerlySense->new()), "new ok");
129 | 1 |  |  |  |  | 221 | $fileOrigin = "$dirData/Game/Object/Worm/Bot.pm";
130 |  |  |  |  |  |  |
131 | 1 |  |  |  |  | 3677 | ok($oDocument->parse(file => $fileOrigin), "Parsed file ok");
132 | 1 |  |  |  |  | 298 | ok($oLocation = $oDocument->oLocationSubDefinition(name => "loadFile", package => "Game::Object::Worm::Bot"), "Found sub in parent package");
133 | 1 |  |  |  |  | 416 | like($oLocation->file, $rexFileDest, " Got file");
134 | 1 |  |  |  |  | 780 | is($oLocation->row, 360, " row");
135 | 1 |  |  |  |  | 218 | is($oLocation->col, 1, " col");
136 |  |  |  |  |  |  |
137 |  |  |  |  |  |  |
138 |  |  |  |  |  |  |
139 |  |  |  |  |  |  |
140 |  |  |  |  |  |  | __END__