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