File Coverage

t/PerlySense-Document-find-pod.t
Criterion Covered Total %
statement 78 78 100.0
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod n/a
total 88 89 98.8


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2 1     1   166269 use strict;
  1         2  
  1         63  
3              
4 1     1   507 use Test::More tests => 44;
  1         15394  
  1         8  
5 1     1   638 use Test::Exception;
  1         3347  
  1         4  
6              
7 1     1   221 use File::Basename;
  1         1  
  1         113  
8 1     1   282 use File::Spec::Functions;
  1         466  
  1         60  
9              
10 1     1   273 use lib "../lib";
  1         575  
  1         4  
11              
12 1     1   106158 use_ok("Devel::PerlySense::Document");
  1         466  
  1         7  
  1         1  
  1         12  
13 1     1   278 use_ok("Devel::PerlySense::Document::Location");
  1         81  
  1         2  
  1         1  
  1         6  
14              
15              
16 1 50   1   1834 BEGIN { -d "t" and chdir("t"); }
17              
18              
19 1         196 ok(my $oDocument = Devel::PerlySense::Document->new(oPerlySense => Devel::PerlySense->new()), "new ok");
20              
21 1         189 my $dirData = "data/simple-lib";
22 1         4 my $fileOrigin = "$dirData/lib/Win32/Word/Writer.pm";
23 1         1 my $oLocation;
24              
25 1         5 ok($oDocument->parse(file => $fileOrigin), "Parsed file ok");
26              
27 1         627 is($oDocument->oLocationPod(name => "sdfasjdfjasdkfj", lookFor => "method"), undef, "Didn't find missing pod line");
28              
29 1         289 ok($oLocation = $oDocument->oLocationPod(name => "Close", lookFor => "method"), "Found correct POD line =head (leading in POD block)");
30 1         218 is($oLocation->file, $fileOrigin, " Got file");
31 1         223 is($oLocation->row, 365, " row");
32 1         214 is($oLocation->col, 1, " col");
33 1         216 is($oLocation->rhProperty->{pod}, q{=head1 METHODS
34              
35             =head2 Close()
36              
37             Discard the current document no-questions-asked (i.e. even if it's not
38             saved).
39              
40             Note that this object is in an unusable state until a new document is
41             created or opened.
42              
43             }, " Got POD");
44 1         214 is($oLocation->rhProperty->{name}, "Close", " Got name ok");
45 1         212 is($oLocation->rhProperty->{docType}, "hint", " Got docType ok");
46 1         208 is($oLocation->rhProperty->{found}, "method", " Got found ok");
47              
48 1         766 ok($oLocation = $oDocument->oLocationPod(name => "Write", lookFor => "method"), "Found correct POD line (inside POD block)");
49 1         234 is($oLocation->file, $fileOrigin, " Got file");
50 1         421 is($oLocation->row, 391, " row");
51 1         420 is($oLocation->col, 1, " col");
52 1         971 is($oLocation->rhProperty->{pod}, q{=head1 METHODS - ADDING TEXT
53              
54             =head2 Write($text)
55              
56             Append $text to the document (using the current style etc).
57              
58             }, " Got POD");
59 1         444 is($oLocation->rhProperty->{name}, "Write", " Got name ok");
60 1         413 is($oLocation->rhProperty->{docType}, "hint", " Got docType ok");
61 1         855 is($oLocation->rhProperty->{found}, "method", " Got found ok");
62              
63              
64 1         429 ok($oLocation = $oDocument->oLocationPod(name => "hasWrittenParagraph", lookFor => "method"), "Found correct POD line =item");
65 1         253 is($oLocation->file, $fileOrigin, " Got file");
66 1         217 is($oLocation->row, 1193, " row");
67 1         212 is($oLocation->col, 1, " col");
68 1         211 is($oLocation->rhProperty->{pod}, q{=head1 PRIVATE PROPERTIES
69              
70             =over 4
71              
72             =item hasWrittenParagraph
73              
74             Whether the writer has written a paragraph yet.
75              
76              
77              
78              
79             =back
80             }, " Got POD");
81 1         211 is($oLocation->rhProperty->{name}, "hasWrittenParagraph", " Got name ok");
82 1         210 is($oLocation->rhProperty->{docType}, "hint", " Got docType ok");
83 1         211 is($oLocation->rhProperty->{found}, "method", " Got found ok");
84              
85              
86 1         189 ok($oLocation = $oDocument->oLocationPod(name => "hasWrittenText", lookFor => "method"), "Found correct POD line =item (B<>)");
87 1         628 is($oLocation->file, $fileOrigin, " Got file");
88 1         241 is($oLocation->row, 1198, " row");
89 1         224 is($oLocation->col, 1, " col");
90 1         213 is($oLocation->rhProperty->{pod}, q{=head1 PRIVATE PROPERTIES
91              
92             =over 4
93              
94             =item B<hasWrittenText>
95              
96             Whether the writer has written any text or paragraph yet.
97              
98              
99              
100              
101             =back
102             }, " Got POD");
103 1         211 is($oLocation->rhProperty->{name}, "hasWrittenText", " Got name ok");
104 1         212 is($oLocation->rhProperty->{docType}, "hint", " Got docType ok");
105 1         222 is($oLocation->rhProperty->{found}, "method", " Got found ok");
106              
107              
108              
109              
110              
111 1         192 note("Base classes");
112              
113 1         54 $dirData = "data/project-lib";
114 1         6 my $rexFileDest = qr/Game.Object.Worm.pm/;
115              
116 1         9 ok($oDocument = Devel::PerlySense::Document->new(oPerlySense => Devel::PerlySense->new()), "new ok");
117 1         211 $fileOrigin = "$dirData/Game/Object/Worm/Bot.pm";
118 1         23832 ok($oDocument->parse(file => $fileOrigin), "Parsed file ok");
119              
120              
121              
122 1         295 ok(! $oDocument->oLocationPod(name => "loadFile", lookFor => "method", ignoreBaseModules => 1), "Did not find anything in current package only");
123              
124              
125              
126 1         198 ok($oLocation = $oDocument->oLocationPod(name => "loadFile", lookFor => "method"), "Found correct POD in base package");
127 1         353 like($oLocation->file, $rexFileDest, " Got file");
128 1         220 is($oLocation->row, 355, " row");
129 1         517 is($oLocation->col, 1, " col");
130              
131              
132              
133              
134              
135             __END__