File: 20_parse_self.t

package info (click to toggle)
libmodule-extractuse-perl 0.344-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 868 kB
  • sloc: perl: 11,270; makefile: 17
file content (58 lines) | stat: -rw-r--r-- 1,881 bytes parent folder | download | duplicates (3)
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
57
58
#!/usr/bin/perl -w
use strict;
use Test::More tests=>13;
use Test::Deep;
use Test::NoWarnings;
use Module::ExtractUse;

# test testfile
{
    my $p=Module::ExtractUse->new;
    my @used=$p->extract_use($0)->array;
    cmp_deeply(\@used,
	       bag(qw(strict Test::More Test::Deep Test::NoWarnings Module::ExtractUse)),
	       'modules used in this test script'
	      );
    @used=$p->extract_use($0)->array_in_eval;
    cmp_deeply(\@used,
	       [],
	       'optional modules used in this test script'
	      );
    @used=$p->extract_use($0)->array_out_of_eval;
    cmp_deeply(\@used,
	       bag(qw(strict Test::More Test::Deep Test::NoWarnings Module::ExtractUse)),
	       'mandatory modules used in this test script'
	      );
}

# test Module::ExtractUse
{
    my $p=Module::ExtractUse->new;
    $p->extract_use('lib/Module/ExtractUse.pm');
    cmp_deeply($p->arrayref,
	       bag(qw(strict warnings Pod::Strip Parse::RecDescent Module::ExtractUse::Grammar Carp 5.008)),
	       'modules used in this Module::ExtractUsed');
    cmp_deeply([$p->arrayref_in_eval],
	       [],
	       'optional modules used in this Module::ExtractUsed');
    cmp_deeply($p->arrayref_out_of_eval,
	       bag(qw(strict warnings Pod::Strip Parse::RecDescent Module::ExtractUse::Grammar Carp 5.008)),
	       'mandatory modules used in this Module::ExtractUsed');

    my $used=$p->used;
    is($used->{'strict'},1,'strict via hash lookup');

    is($p->used('strict'),1,'strict via used method');

    my $used_in_eval=$p->used_in_eval;
    is(!$used_in_eval->{'strict'},1,'strict via in-eval hash lookup');

    is(!$p->used_in_eval('strict'),1,'strict via used_in_eval method');

    my $used_out_of_eval=$p->used_out_of_eval;
    is($used_out_of_eval->{'strict'},1,'strict via out-of-eval hash lookup');

    is($p->used_out_of_eval('strict'),1,'strict via used_out_of_eval method');

}