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