Revision history for Config-Any
- - Show actual parse error when parse fails (Marcus Ramberg).
+0.13 XXX
+ - show actual parse error when parse fails (Marcus Ramberg)
+ - ensure Config::Tiny parse errors are trapped
+ - added tests for each format to ensure they throw parse errors
0.12 Mon 07 Apr 2008
- ensure Perl loader dies on a failed require() (RT #32995)
use Carp;
use Module::Pluggable::Object ();
-our $VERSION = '0.12';
+our $VERSION = '0.13';
=head1 NAME
require Config::Tiny;
my $config = Config::Tiny->read( $file );
+
+ die $Config::Tiny::errstr if not defined $config;
+
my $out = delete $config->{ _ } || {};
for my $k ( keys %$config ) {
plan skip_all => 'Config::General format not supported';
}
else {
- plan tests => 4;
+ plan tests => 6;
}
{
{ -LowerCaseNames => 1 } );
ok( exists $config->{ component } );
}
+
+# test invalid config
+{
+ my $file = 't/invalid/conf.conf';
+ my $config = eval { Config::Any::General->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
plan skip_all => 'INI format not supported';
}
else {
- plan tests => 11;
+ plan tests => 13;
}
{
ok( $config, 'config loaded' );
is_deeply( $config, \%expected, 'subsections parsed properly' );
}
+
+# test invalid config
+{
+ my $file = 't/invalid/conf.ini';
+ my $config = eval { Config::Any::INI->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
plan skip_all => 'JSON format not supported';
}
else {
- plan tests => 2;
+ plan tests => 4;
}
{
ok( $config );
is( $config->{ name }, 'TestApp' );
}
+
+# test invalid config
+{
+ my $file = 't/invalid/conf.json';
+ my $config = eval { Config::Any::JSON->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 5;
use Config::Any::Perl;
is_deeply( $config_load2, $config, 'multiple loads of the same file' );
}
+# test invalid config
+{
+ my $file = 't/invalid/conf.pl';
+ my $config = eval { Config::Any::Perl->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
plan skip_all => 'XML format not supported';
}
else {
- plan tests => 2;
+ plan tests => 4;
}
{
ok( $config );
is( $config->{ name }, 'TestApp' );
}
+
+# test invalid config
+{
+ my $file = 't/invalid/conf.xml';
+ my $config = eval { Config::Any::XML->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
plan skip_all => 'YAML format not supported';
}
else {
- plan tests => 2;
+ plan tests => 4;
}
{
ok( $config );
is( $config->{ name }, 'TestApp' );
}
+
+# test invalid config
+{
+ my $file = 't/invalid/conf.yml';
+ my $config = eval { Config::Any::YAML->load( $file ) };
+
+ ok( !$config, 'config load failed' );
+ ok( $@, "error thrown ($@)" );
+}
+++ /dev/null
-use strict;
-use warnings;
-
-use Test::More tests => 2;
-
-use Config::Any::Perl;
-
-{
- my $file = 't/conf/conf_invalid.pl';
- my $config = eval { Config::Any::Perl->load( $file ) };
-
- ok( !$config, 'config load failed' );
- ok( $@, "error thrown ($@)" );
-}
+++ /dev/null
-this is not valid perl.
--- /dev/null
+name = TestApp\r
+<Component Controller::Foo\r
+ foo bar\r
+</Component>\r
+<Model Model::Baz>\r
+ qux xyzzy\r
+</Model>\r
--- /dev/null
+name=TestApp\r
+ \r
+[Component Controller::Foo\r
+foo=bar\r
+\r
+[Model Model::Baz]\r
+qux=xyzzy\r
--- /dev/null
+{\r
+ "name": "TestApp",\r
+ "Component": {\r
+ "Controller::Foo": {\r
+ "foo": "bar"\r
+ }\r
+ },\r
+ "Model": {\r
+ "Model::Baz": {\r
+ "qux": "xyzzy"\r
+ }\r
+ }\r
+
--- /dev/null
+{ name => 'TestApp'
+ Component => { 'Controller::Foo' => { foo => 'bar' } },
+ Model => { 'Model::Baz' => { qux => 'xyzzy' } }
+}
--- /dev/null
+<config>
+ <name>TestApp</name
+ <Component name="Controller::Foo">
+ <foo>bar</foo>
+ </Component>
+ <Model name="Model::Baz">
+ <qux>xyzzy</qux>
+ </Model>
+</config>
--- /dev/null
+---
+name: TestApp
+Component:
+ Controller::Foo:
+ foo: bar
+Model:
+ Model::Baz:
+ qux: xyzzy