Test load_files throws parse errors when use_ext=1
[p5sagit/Config-Any.git] / t / 54-xml.t
index 41376ac..0d546cb 100644 (file)
@@ -2,13 +2,14 @@ use strict;
 use warnings;
 
 use Test::More;
+use Config::Any;
 use Config::Any::XML;
 
 if ( !Config::Any::XML->is_supported ) {
     plan skip_all => 'XML format not supported';
 }
 else {
-    plan tests => 4;
+    plan tests => 8;
 }
 
 {
@@ -19,13 +20,33 @@ else {
 
 # test invalid config
 SKIP: {
-    my $broken_libxml = eval { require XML::LibXML; XML::LibXML->VERSION lt '1.59'; };
+    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
+    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 ($@)" );
+    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' );
+}
+
+# parse error generated on invalid config
+{
+    my $file = 't/invalid/conf.xml';
+    my $config = eval { Config::Any->load_files( { files => [$file], use_ext => 1} ) };
+
+    ok( !$config, 'config load failed' );
+    ok( $@,       "error thrown ($@)" );
+}
+