Commit | Line | Data |
5a2e0210 |
1 | use strict; |
2 | use warnings; |
f0e3c221 |
3 | |
5a2e0210 |
4 | use Test::More; |
f0e3c221 |
5 | use Config::Any::XML; |
6 | |
5a2e0210 |
7 | if ( !Config::Any::XML->is_supported ) { |
8 | plan skip_all => 'XML format not supported'; |
9 | } |
10 | else { |
5770ffc0 |
11 | plan tests => 4; |
5a2e0210 |
12 | } |
f0e3c221 |
13 | |
5a2e0210 |
14 | { |
15 | my $config = Config::Any::XML->load( 't/conf/conf.xml' ); |
f0e3c221 |
16 | ok( $config ); |
17 | is( $config->{ name }, 'TestApp' ); |
18 | } |
5770ffc0 |
19 | |
20 | # test invalid config |
9d569cf0 |
21 | SKIP: { |
22 | my $broken_libxml = eval { require XML::LibXML; XML::LibXML->VERSION lt '1.59'; }; |
23 | skip 'XML::LibXML < 1.58 has issues', 2 if $broken_libxml; |
24 | |
25 | local $SIG{__WARN__} = sub {}; # squash warnings from XML::Simple |
77f14cda |
26 | my $file = 't/invalid/conf.xml'; |
5770ffc0 |
27 | my $config = eval { Config::Any::XML->load( $file ) }; |
28 | |
29 | ok( !$config, 'config load failed' ); |
77f14cda |
30 | ok( $@, "error thrown ($@)" ); |
5770ffc0 |
31 | } |