-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path10-branches.t
75 lines (63 loc) · 1.69 KB
/
10-branches.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use strict;
use warnings;
no warnings 'once';
# use Test::Without::Module qw(YAML YAML::Syck Config::General XML::Simple JSON JSON::Syck Config::Tiny );
use Test::More tests => 9;
use Config::Any;
use Config::Any::YAML;
{
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 args"
);
Config::Any->load_stems( {} );
like(
shift @warnings,
qr/^No stems specified!/,
"load_stems expects stems"
);
}
my @files = glob( "t/supported/conf.*" );
{
require Config::Any::General;
local $SIG{ __WARN__ } = sub { }
if Config::Any::General->is_supported;
ok( Config::Any->load_files( { files => \@files, use_ext => 0 } ),
"use_ext 0 works" );
}
my $filter = sub { return };
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 "reject" }
}
);
};
like $@, qr/reject/, "filter breaks";
my @stems = qw(t/supported/conf);
ok( Config::Any->load_stems( { stems => \@stems, use_ext => 1 } ),
"load_stems with stems works" );