File: 79273.t

package info (click to toggle)
libmodule-extract-use-perl 1.047-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 184 kB
  • sloc: perl: 572; makefile: 2
file content (56 lines) | stat: -rwxr-xr-x 1,474 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl
use strict;

use Test::More tests => 6;
use File::Basename;
use File::Spec::Functions qw(catfile);

my $class = "Module::Extract::Use";
use_ok( $class );

my $extor = $class->new;
isa_ok( $extor, $class );
can_ok( $extor, 'get_modules_with_details' );


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Try it with a file that has repeated use lines
# I should only get unique names
{
my $file = catfile( qw(corpus RT79273.pm) );
ok( -e $file, "Test file [$file] is there" );

my $details = $extor->get_modules_with_details( $file );
is( scalar @$details, 3, 'There are the right number of hits' );

is_deeply( $details, expected(), 'The data structures match' );
}

sub expected {
	return  [
          {
          	'direct'  => 1,
            'content' => 'use parent \'CGI::Snapp\';',
            'pragma'  => 'parent',
            'version' => undef,
            'imports' => [qw(CGI::Snapp)],
            'module'  => 'parent'
          },
          {
          	'direct'  => 1,
            'content' => 'use Capture::Tiny \'capture\';',
            'pragma' => '',
            'version' => undef,
            'imports' => [qw(capture)],
            'module' => 'Capture::Tiny'
          },
          {
          	'direct'  => 0,
            'content' => 'use parent \'CGI::Snapp\';',
            'pragma'  => '',
            'version' => undef,
            'imports' => [],
            'module'  => 'CGI::Snapp'
          },
	];
	}