remove version section from pod
[p5sagit/Config-Any.git] / t / 51-ini.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Config::Any::INI;
6
7 if ( !Config::Any::INI->is_supported ) {
8     plan skip_all => 'INI format not supported';
9 }
10 else {
11     plan tests => 11;
12 }
13
14 {
15     my $config = Config::Any::INI->load( 't/conf/conf.ini' );
16     ok( $config, 'config loaded' );
17     is( $config->{ name }, 'TestApp', "toplevel key lookup succeeded" );
18     is( $config->{ Component }->{ 'Controller::Foo' }->{ foo },
19         'bar', "nested hashref hack lookup succeeded" );
20 }
21
22 {
23     my $config = Config::Any::INI->load( 't/conf/conf2.ini' );
24     ok( $config, 'config loaded' );
25     is( $config->{ name }, 'TestApp', "toplevel key lookup succeeded" );
26     is( $config->{ 'Controller::Foo' }->{ foo },
27         'bar', "nested hashref hack lookup succeeded" );
28 }
29
30 {
31     local $Config::Any::INI::MAP_SECTION_SPACE_TO_NESTED_KEY = 0;
32     my $config = Config::Any::INI->load( 't/conf/conf.ini' );
33     ok( $config, 'config loaded (no-map-space mode)' );
34     is( $config->{ name }, 'TestApp', "toplevel key lookup succeeded" );
35     is( $config->{ 'Component Controller::Foo' }->{ foo },
36         'bar', "unnested key lookup succeeded" );
37 }
38
39 {
40     my $config = Config::Any::INI->load( 't/conf/subsections.ini' );
41
42     my %expected
43         = ( section1 =>
44             { a => 1, subsection1 => { b => 2 }, subsection2 => { c => 3 } }
45         );
46     ok( $config, 'config loaded' );
47     is_deeply( $config, \%expected, 'subsections parsed properly' );
48 }