prep release
[p5sagit/Config-Any.git] / t / 10-branches.t
CommitLineData
5a2e0210 1use strict;
2use warnings;
3
803bbb11 4# use Test::Without::Module qw(YAML YAML::Syck Config::General XML::Simple JSON JSON::Syck Config::Tiny );
bef9e9a5 5use Test::More tests => 10;
f0e3c221 6
bef9e9a5 7use_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 42my @files = glob( "t/supported/conf.*" );
26e3cdf4 43{
44 require Config::Any::General;
45 local $SIG{ __WARN__ } = sub { }
46 if Config::Any::General->is_supported;
47 ok( Config::Any->load_files( { files => \@files, use_ext => 0 } ),
48 "use_ext 0 works" );
49}
0ac17764 50
51my $filter = sub { return };
92a04e78 52ok( Config::Any->load_files( { files => \@files, use_ext => 1 } ),
53 "use_ext 1 works" );
f0e3c221 54
92a04e78 55ok( Config::Any->load_files(
56 { files => \@files, use_ext => 1, filter => \&$filter }
57 ),
58 "filter works"
59);
60eval {
61 Config::Any->load_files(
62 { files => \@files,
63 use_ext => 1,
64 filter => sub { die }
65 }
66 );
67};
68ok( $@, "filter breaks" );
f0e3c221 69
803bbb11 70my @stems = qw(t/supported/conf);
92a04e78 71ok( Config::Any->load_stems( { stems => \@stems, use_ext => 1 } ),
72 "load_stems with stems works" );