X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F040_basic_utils.t;h=4d3f803530f9f02debe4c56ee928759508452a20;hb=c2d52f94beb56939250944a12df15d7d90779866;hp=802e841ab6993d819717b63e2935a94e690c687b;hpb=69b45b7d79fa7628879179765a6deba184f92fdf;p=gitmo%2FMooseX-Storage.git diff --git a/t/040_basic_utils.t b/t/040_basic_utils.t index 802e841..4d3f803 100644 --- a/t/040_basic_utils.t +++ b/t/040_basic_utils.t @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings; @@ -7,7 +5,7 @@ use Test::More tests => 5; BEGIN { use_ok('MooseX::Storage'); - use_ok('MooseX::Storage::Util'); + use_ok('MooseX::Storage::Util'); } my $packed = { @@ -17,16 +15,16 @@ my $packed = { float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - number => 2 - }, + object => { + __CLASS__ => 'Foo', + number => 2 + }, }; my $json = '{"array":[1,2,3,4,5,6,7,8,9,10],"hash":{"6":null,"3":null,"7":null,"9":null,"2":null,"8":null,"1":null,"4":null,"10":null,"5":null},"float":10.5,"object":{"number":2,"__CLASS__":"Foo"},"number":10,"__CLASS__":"Foo","string":"foo"}'; -my $yaml = q{--- +my $yaml = q{--- __CLASS__: Foo -array: +array: - 1 - 2 - 3 @@ -38,7 +36,7 @@ array: - 9 - 10 float: 10.5 -hash: +hash: 1: ~ 10: ~ 2: ~ @@ -50,25 +48,39 @@ hash: 8: ~ 9: ~ number: 10 -object: +object: __CLASS__: Foo number: 2 string: foo }; -is( -'Foo', -MooseX::Storage::Util->peek($packed), -'... got the right class name from the packed item'); +is('Foo', MooseX::Storage::Util->peek($packed), + '... got the right class name from the packed item'); + +SKIP: { + my $classname = eval { + MooseX::Storage::Util->peek($json => ('format' => 'JSON')) + }; + if ($@ =~ /^Could not load JSON module because/) { + die 'No JSON module found' if $ENV{AUTHOR_TESTING}; + skip "No JSON module found", 1; + } -is( -'Foo', -MooseX::Storage::Util->peek($json => ('format' => 'JSON')), -'... got the right class name from the json item'); + is('Foo', $classname, + '... got the right class name from the json item'); +} -is( -'Foo', -MooseX::Storage::Util->peek($yaml => ('format' => 'YAML')), -'... got the right class name from the yaml item'); +SKIP: { + my $classname = eval { + MooseX::Storage::Util->peek($yaml => ('format' => 'YAML')) + }; + if ($@ =~ /^Could not load YAML module because/) { + die 'No YAML module found' if $ENV{AUTHOR_TESTING}; + skip "No YAML module found", 1; + } + + is('Foo', $classname, + '... got the right class name from the yaml item'); +}