File Coverage

t/PerlySense-find-file-up-down.t
Criterion Covered Total %
statement 47 47 100.0
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod n/a
total 57 58 98.2


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2 1     1   154019 use strict;
  1         2  
  1         64  
3              
4 1     1   523 use Test::More tests => 8;
  1         16852  
  1         8  
5 1     1   696 use Test::Exception;
  1         5924  
  1         4  
6              
7 1     1   230 use File::Basename;
  1         1  
  1         103  
8 1     1   349 use File::Spec::Functions;
  1         522  
  1         62  
9              
10 1     1   287 use lib "../lib";
  1         546  
  1         4  
11              
12 1     1   73670 use_ok("Devel::PerlySense");
  1         614  
  1         1  
  1         2  
  1         6  
13              
14              
15 1 50   1   1940 BEGIN { -d "t" and chdir("t"); }
16              
17              
18 1         278 ok(my $oPs = Devel::PerlySense->new(), "new ok");
19              
20              
21              
22             {
23 1         198 my $dirData = "data/simple-lib";
  1         2  
24 1         2 my $fileOrigin = "$dirData/lib/Win32/Word/Writer.pm";
25 1         58 my $dirOrigin = dirname($fileOrigin);
26 1         2 my $nameModule = "Win32::Word::Writer::Table2";
27 1         4 my $fileModuleTarget = catfile("Writer", "Table2.pm");
28              
29              
30 1     1   44 throws_ok( sub { $oPs->fileFindModule() }, qr/nameModule/, "fileFindModule dies ok with missing param");
  1         34  
31              
32 1         771 is($oPs->fileFindModule(nameModule => $nameModule, dirOrigin => "fsdlkj/sdfsdjk"), undef, "Didn't find file ok");
33 1         233 is($oPs->fileFindModule(nameModule => "FLorjsdkdj", dirOrigin => $dirOrigin), undef, "Didn't find file ok");
34              
35 1         208 like($oPs->fileFindModule(nameModule => $nameModule, dirOrigin => $dirOrigin), qr/ \Q$fileModuleTarget\E $/x, "Found file downwards ok");
36              
37              
38 1         308 note("Check that the file without the prefix of the main file is found and not shadowed by it");
39 1         49 my $nameModuleShadowed = "Word::Writer";
40 1         4 my $fileModuleShadowedTarget = catfile("lib", "Word", "Writer.pm");
41 1         21 like(
42             $oPs->fileFindModule(nameModule => $nameModuleShadowed, dirOrigin => $dirOrigin),
43             qr/ \Q$fileModuleShadowedTarget\E $/x,
44             "Found file downwards ok even though it might have been shadowed by the longer name",
45             );
46             }
47              
48              
49             {
50 1         292 my $dirData = "data/simple-lib";
  1         2  
51 1         3 my $fileOrigin = "$dirData/lib/Win32/Word/Writer/Table2.pm";
52 1         48 my $dirOrigin = dirname($fileOrigin);
53 1         2 my $nameModule = "Win32::Word::Writer";
54 1         6 my $fileModuleTarget = catfile("..", "Writer.pm");
55              
56 1         19 like($oPs->fileFindModule(nameModule => $nameModule, dirOrigin => $dirOrigin), qr/ Writer\.pm $/x, "Found file upwards ok");
57             }
58              
59              
60              
61              
62              
63              
64             __END__