Commit | Line | Data |
1a04e791 |
1 | use strict; |
2 | use Test::More 'no_plan'; |
3 | |
4 | BEGIN { chdir 't' if -d 't' }; |
5 | use lib '../lib'; |
6 | |
7 | my $Class = 'Package::Constants'; |
8 | my $Func = 'list'; |
9 | my $Pkg = '_test'; |
10 | my @Good = 'A'..'C'; |
11 | my @Bad = 'D'..'E'; |
12 | |
13 | use_ok( $Class ); |
14 | can_ok( $Class, $Func ); |
15 | |
16 | ### enable debug statements? |
17 | $Package::Constants::DEBUG = $Package::Constants::DEBUG = @ARGV ? 1 : 0; |
18 | |
19 | |
20 | ### small test class |
21 | { package _test; |
22 | |
23 | ### mark us as loaded |
24 | $INC{'_test.pm'} = $0; |
25 | |
26 | use vars qw[$FOO]; |
27 | $FOO = 1; |
28 | |
29 | ### define various subs.. the first 3 are constants, |
30 | ### the others are not |
31 | use constant A => 1; |
32 | use constant B => sub { 1 }; |
33 | sub C () { 1 }; |
34 | |
35 | sub D { 1 }; |
36 | sub E (*) { 1 }; |
37 | |
38 | } |
39 | |
40 | ### get the list |
41 | { my @list = $Class->$Func( $Pkg ); |
42 | ok( scalar(@list), "Got a list of constants" ); |
43 | is_deeply( \@list, \@Good, " Contains all expected entries" ); |
44 | } |
45 | |
46 | |
47 | # Local variables: |
48 | # c-indentation-style: bsd |
49 | # c-basic-offset: 4 |
50 | # indent-tabs-mode: nil |
51 | # End: |
52 | # vim: expandtab shiftwidth=4: |