fix up branches test which did not handle the errors thrown by changes from the last...
[p5sagit/Config-Any.git] / t / 10-branches.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 10;
5
6 use_ok( 'Config::Any' );
7
8 {
9     my @warnings;
10     local $SIG{ __WARN__ } = sub { push @warnings, @_ };
11
12     Config::Any->load_files();
13     like(
14         shift @warnings,
15         qr/^No files specified!/,
16         "load_files expects args"
17     );
18
19     Config::Any->load_files( {} );
20     like(
21         shift @warnings,
22         qr/^No files specified!/,
23         "load_files expects files"
24     );
25
26     Config::Any->load_stems();
27     like(
28         shift @warnings,
29         qr/^No stems specified!/,
30         "load_stems expects args"
31     );
32
33     Config::Any->load_stems( {} );
34     like(
35         shift @warnings,
36         qr/^No stems specified!/,
37         "load_stems expects stems"
38     );
39 }
40
41 # can only be sure that perl files will load
42 my @files = ( 't/conf/conf.pl' );
43 ok( Config::Any->load_files( { files => \@files, use_ext => 0 } ),
44     "use_ext 0 works" );
45
46 my $filter = sub { return };
47 ok( Config::Any->load_files( { files => \@files, use_ext => 1 } ),
48     "use_ext 1 works" );
49
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" );
64
65 my @stems = qw(t/conf/conf);
66 ok( Config::Any->load_stems( { stems => \@stems, use_ext => 1 } ),
67     "load_stems with stems works" );