Commit | Line | Data |
5a2e0210 |
1 | use strict; |
2 | use warnings; |
3 | |
803bbb11 |
4 | # use Test::Without::Module qw(YAML YAML::Syck Config::General XML::Simple JSON JSON::Syck Config::Tiny ); |
bef9e9a5 |
5 | use Test::More tests => 10; |
f0e3c221 |
6 | |
bef9e9a5 |
7 | use_ok( 'Config::Any' ); |
f0e3c221 |
8 | |
9 | { |
10 | my @warnings; |
92a04e78 |
11 | local $SIG{ __WARN__ } = sub { push @warnings, @_ }; |
4efab558 |
12 | |
72628dc7 |
13 | Config::Any->load_files(); |
4efab558 |
14 | like( |
15 | shift @warnings, |
16 | qr/^No files specified!/, |
17 | "load_files expects args" |
18 | ); |
19 | |
92a04e78 |
20 | Config::Any->load_files( {} ); |
21 | like( |
22 | shift @warnings, |
4efab558 |
23 | qr/^No files specified!/, |
92a04e78 |
24 | "load_files expects files" |
25 | ); |
4efab558 |
26 | |
72628dc7 |
27 | Config::Any->load_stems(); |
bef9e9a5 |
28 | like( |
29 | shift @warnings, |
30 | qr/^No stems specified!/, |
31 | "load_stems expects args" |
32 | ); |
33 | |
92a04e78 |
34 | Config::Any->load_stems( {} ); |
35 | like( |
36 | shift @warnings, |
bef9e9a5 |
37 | qr/^No stems specified!/, |
92a04e78 |
38 | "load_stems expects stems" |
39 | ); |
f0e3c221 |
40 | } |
41 | |
803bbb11 |
42 | my @files = glob( "t/supported/conf.*" ); |
92a04e78 |
43 | ok( Config::Any->load_files( { files => \@files, use_ext => 0 } ), |
44 | "use_ext 0 works" ); |
0ac17764 |
45 | |
46 | my $filter = sub { return }; |
92a04e78 |
47 | ok( Config::Any->load_files( { files => \@files, use_ext => 1 } ), |
48 | "use_ext 1 works" ); |
f0e3c221 |
49 | |
92a04e78 |
50 | ok( Config::Any->load_files( |
51 | { files => \@files, use_ext => 1, filter => \&$filter } |
52 | ), |
53 | "filter works" |
54 | ); |
55 | eval { |
56 | Config::Any->load_files( |
57 | { files => \@files, |
58 | use_ext => 1, |
59 | filter => sub { die } |
60 | } |
61 | ); |
62 | }; |
63 | ok( $@, "filter breaks" ); |
f0e3c221 |
64 | |
803bbb11 |
65 | my @stems = qw(t/supported/conf); |
92a04e78 |
66 | ok( Config::Any->load_stems( { stems => \@stems, use_ext => 1 } ), |
67 | "load_stems with stems works" ); |