File: 01_list.t

package info (click to toggle)
libpackage-constants-perl 0.06-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 76 kB
  • sloc: perl: 30; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,068 bytes parent folder | download | duplicates (8)
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
use strict;
use Test::More 'no_plan';

BEGIN { chdir 't' if -d 't' };
use lib '../lib';

my $Class   = 'Package::Constants';
my $Func    = 'list';
my $Pkg     = '_test';
my @Good    = 'A'..'C';
my @Bad     = 'D'..'E';

use_ok( $Class );
can_ok( $Class, $Func );

### enable debug statements?
$Package::Constants::DEBUG = $Package::Constants::DEBUG = @ARGV ? 1 : 0;


### small test class 
{   package _test;

    ### mark us as loaded
    $INC{'_test.pm'} = $0;
    
    use vars qw[$FOO];
    $FOO = 1;
    
    ### define various subs.. the first 3 are constants, 
    ### the others are not
    use constant A => 1;
    use constant B => sub { 1 };
    sub C ()        { 1 };
    
    sub D           { 1 };
    sub E (*)       { 1 };

}    

### get the list
{   my @list = $Class->$Func( $Pkg );
    ok( scalar(@list),          "Got a list of constants" );
    is_deeply( \@list, \@Good,  "   Contains all expected entries" );
}    


# Local variables:
# c-indentation-style: bsd
# c-basic-offset: 4
# indent-tabs-mode: nil
# End:
# vim: expandtab shiftwidth=4: