File: 54-xml.t

package info (click to toggle)
libconfig-any-perl 0.23-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 340 kB
  • sloc: perl: 1,578; xml: 28; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 976 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;

use Test::More;
use Config::Any::XML;

if ( !Config::Any::XML->is_supported ) {
    plan skip_all => 'XML format not supported';
}
else {
    plan tests => 6;
}

{
    my $config = Config::Any::XML->load( 't/conf/conf.xml' );
    ok( $config );
    is( $config->{ name }, 'TestApp' );
}

# test invalid config
SKIP: {
    my $broken_libxml
        = eval { require XML::LibXML; XML::LibXML->VERSION lt '1.59'; };
    skip 'XML::LibXML < 1.58 has issues', 2 if $broken_libxml;

    local $SIG{ __WARN__ } = sub { };    # squash warnings from XML::Simple
    my $file = 't/invalid/conf.xml';
    my $config = eval { Config::Any::XML->load( $file ) };

    ok( !$config, 'config load failed' );
    ok( $@,       "error thrown ($@)" );
}

# test conf file with array ref
{
    my $file = 't/conf/conf_arrayref.xml';
    my $config = eval { Config::Any::XML->load( $file ) };

    ok( $config, 'config loaded' );
    ok( !$@,     'no error thrown' );
}