added a caveat regarding XML::Simple's strict mode (Peter Corlett)
[p5sagit/Config-Any.git] / t / 52-json.t
index dcf084f..23eb920 100644 (file)
@@ -1,11 +1,27 @@
-use Test::More tests => 2;
+use strict;
+use warnings;
 
+use Test::More;
 use Config::Any::JSON;
 
-my $config = eval { Config::Any::JSON->load( 't/conf/conf.json' ) };
+if ( !Config::Any::JSON->is_supported ) {
+    plan skip_all => 'JSON format not supported';
+}
+else {
+    plan tests => 4;
+}
 
-SKIP: {
-    skip "Couldn't Load JSON plugin", 2 if $@;
+{
+    my $config = Config::Any::JSON->load( 't/conf/conf.json' );
     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 ($@)" ); 
+}