added some branch exercising tests in 10-branches.t and 51-ini.t, and a second INI...
Joel Bernstein [Tue, 22 Aug 2006 21:18:27 +0000 (21:18 +0000)]
t/10-branches.t [new file with mode: 0644]
t/51-ini.t
t/conf/conf2.ini [new file with mode: 0644]

diff --git a/t/10-branches.t b/t/10-branches.t
new file mode 100644 (file)
index 0000000..3e0f400
--- /dev/null
@@ -0,0 +1,27 @@
+use Test::More tests => 9;\r
+use Test::Exception;\r
+use Config::Any;\r
+\r
+ok ( ! Config::Any->load_files(),  "load_files expects args" );\r
+ok ( ! Config::Any->load_stems(),  "load_stems expects args" );\r
+\r
+{\r
+       my @warnings;\r
+       local $SIG{__WARN__} = sub { push @warnings, @_ };\r
+       Config::Any->load_files({});\r
+       like (shift @warnings, qr/^no files specified/, "load_files expects files");\r
+       Config::Any->load_stems({});\r
+       like (shift @warnings, qr/^no stems specified/, "load_stems expects stems");\r
+}\r
+\r
+my @files = glob("t/conf/conf.*");\r
+my $filter = sub { return };\r
+ok(Config::Any->load_files({files=>\@files, use_ext=>0}), "use_ext 0 works");\r
+ok(Config::Any->load_files({files=>\@files, use_ext=>1}), "use_ext 1 works");\r
+\r
+ok(Config::Any->load_files({files=>\@files, use_ext=>1, filter=>\&$filter}), "filter works");\r
+eval {Config::Any->load_files({files=>\@files, use_ext=>1, filter=>sub{die}}) };\r
+ok($@, "filter breaks");\r
+\r
+my @stems = qw(t/conf/conf);\r
+ok(Config::Any->load_stems({stems=>\@stems, use_ext=>1}), "load_stems with stems works");\r
index 206d1a7..17b5bcd 100644 (file)
@@ -1,11 +1,17 @@
-use Test::More tests => 2;\r
+use Test::More tests => 6;\r
 \r
 use Config::Any::INI;\r
 \r
-my $config = eval { Config::Any::INI->load( 't/conf/conf.ini' ) };\r
+my $config =       eval { Config::Any::INI->load( 't/conf/conf.ini' ) };\r
+my $simpleconfig = eval { Config::Any::INI->load( 't/conf/conf2.ini' ) };\r
 \r
 SKIP: {\r
-    skip "Couldn't Load INI plugin", 2 if $@;\r
+    skip "Couldn't Load INI plugin", 6 if $@;\r
     ok( $config );\r
     is( $config->{ name }, 'TestApp' );\r
+       is( $config->{Component}->{Controller::Foo}->{foo}, 'bar');\r
+       \r
+       ok( $simpleconfig );\r
+    is( $simpleconfig->{ name }, 'TestApp' );\r
+    is( $simpleconfig->{Controller::Foo}->{foo}, 'bar' );\r
 }\r
diff --git a/t/conf/conf2.ini b/t/conf/conf2.ini
new file mode 100644 (file)
index 0000000..366619e
--- /dev/null
@@ -0,0 +1,7 @@
+name=TestApp\r
+    \r
+[Controller::Foo]\r
+foo=bar\r
+\r
+[Model::Baz]\r
+qux=xyzzy\r