X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=blobdiff_plain;f=t%2F10-branches.t;h=90dc25b8659f27fb8f6317025e6ff3af52f676db;hp=3e0f400e78c24acb49f49a3945530082e2b95ba0;hb=4efab5582d1ec3acd99a2ffb898bed58d5f2420b;hpb=8587679b9219b55bb8189772981387b0cd70b685 diff --git a/t/10-branches.t b/t/10-branches.t index 3e0f400..90dc25b 100644 --- a/t/10-branches.t +++ b/t/10-branches.t @@ -1,27 +1,56 @@ -use Test::More tests => 9; -use Test::Exception; -use Config::Any; - -ok ( ! Config::Any->load_files(), "load_files expects args" ); -ok ( ! Config::Any->load_stems(), "load_stems expects args" ); - -{ - my @warnings; - local $SIG{__WARN__} = sub { push @warnings, @_ }; - Config::Any->load_files({}); - like (shift @warnings, qr/^no files specified/, "load_files expects files"); - Config::Any->load_stems({}); - like (shift @warnings, qr/^no stems specified/, "load_stems expects stems"); -} - -my @files = glob("t/conf/conf.*"); -my $filter = sub { return }; -ok(Config::Any->load_files({files=>\@files, use_ext=>0}), "use_ext 0 works"); -ok(Config::Any->load_files({files=>\@files, use_ext=>1}), "use_ext 1 works"); - -ok(Config::Any->load_files({files=>\@files, use_ext=>1, filter=>\&$filter}), "filter works"); -eval {Config::Any->load_files({files=>\@files, use_ext=>1, filter=>sub{die}}) }; -ok($@, "filter breaks"); - -my @stems = qw(t/conf/conf); -ok(Config::Any->load_stems({stems=>\@stems, use_ext=>1}), "load_stems with stems works"); +use Test::More tests => 9; +use Config::Any; + +ok( !Config::Any->load_stems(), "load_stems expects args" ); + +{ + my @warnings; + local $SIG{ __WARN__ } = sub { push @warnings, @_ }; + + Config::Any->load_files( ); + like( + shift @warnings, + qr/^No files specified!/, + "load_files expects args" + ); + + Config::Any->load_files( {} ); + like( + shift @warnings, + qr/^No files specified!/, + "load_files expects files" + ); + + Config::Any->load_stems( {} ); + like( + shift @warnings, + qr/^no stems specified/, + "load_stems expects stems" + ); +} + +my @files = glob( "t/conf/conf.*" ); +my $filter = sub { return }; +ok( Config::Any->load_files( { files => \@files, use_ext => 0 } ), + "use_ext 0 works" ); +ok( Config::Any->load_files( { files => \@files, use_ext => 1 } ), + "use_ext 1 works" ); + +ok( Config::Any->load_files( + { files => \@files, use_ext => 1, filter => \&$filter } + ), + "filter works" +); +eval { + Config::Any->load_files( + { files => \@files, + use_ext => 1, + filter => sub { die } + } + ); +}; +ok( $@, "filter breaks" ); + +my @stems = qw(t/conf/conf); +ok( Config::Any->load_stems( { stems => \@stems, use_ext => 1 } ), + "load_stems with stems works" );