Test load_files throws parse errors when use_ext=1
[p5sagit/Config-Any.git] / t / 53-perl.t
CommitLineData
5a2e0210 1use strict;
2use warnings;
3
67a1cd50 4use Test::More tests => 7;
5use Config::Any;
f0e3c221 6use Config::Any::Perl;
7
5a2e0210 8{
9 my $file = 't/conf/conf.pl';
10 my $config = Config::Any::Perl->load( $file );
83020fbd 11
f0e3c221 12 ok( $config );
13 is( $config->{ name }, 'TestApp' );
83020fbd 14
5a2e0210 15 my $config_load2 = Config::Any::Perl->load( $file );
16 is_deeply( $config_load2, $config, 'multiple loads of the same file' );
f0e3c221 17}
5a2e0210 18
5770ffc0 19# test invalid config
20{
77f14cda 21 my $file = 't/invalid/conf.pl';
5770ffc0 22 my $config = eval { Config::Any::Perl->load( $file ) };
23
24 ok( !$config, 'config load failed' );
dcfb1d1d 25 ok( $@, "error thrown ($@)" );
5770ffc0 26}
67a1cd50 27
28# parse error generated on invalid config
29{
30 my $file = 't/invalid/conf.pl';
31 my $config = eval { Config::Any->load_files( { files => [$file], use_ext => 1} ) };
32
33 ok( !$config, 'config load failed' );
34 ok( $@, "error thrown ($@)" );
35}