X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F030_with_checksum.t;h=e38986a151b4291eeb97322b3393676bc3b91601;hb=3f3dcd72365ac2254a802c0f77bbecc3a02c7b84;hp=fc655e27ac0aadc7a331726cd2732f7b2aa63db5;hpb=a7f358fb48a26700a3683db2a10a12660cf4a189;p=gitmo%2FMooseX-Storage.git diff --git a/t/030_with_checksum.t b/t/030_with_checksum.t index fc655e2..e38986a 100644 --- a/t/030_with_checksum.t +++ b/t/030_with_checksum.t @@ -1,21 +1,22 @@ -#!/usr/bin/perl - use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Test::Deep; +use Test::Requires { + 'Digest' => 0.01, # skip all if not installed + 'Digest::SHA' => 0.00, + 'JSON::Any' => 0.01, +}; + BEGIN { - eval "use Digest; use Digest::SHA1"; - plan skip_all => "Digest and Digest::SHA1 is required for this test" if $@; plan tests => 26; use_ok('MooseX::Storage'); } { - package Foo; use Moose; use MooseX::Storage; @@ -40,9 +41,9 @@ BEGIN { object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); - + my $packed = $foo->pack; - + cmp_deeply( $packed, { @@ -53,21 +54,21 @@ BEGIN { float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - __DIGEST__ => re('[0-9a-f]+'), - number => 2 - }, + object => { + __CLASS__ => 'Foo', + __DIGEST__ => re('[0-9a-f]+'), + number => 2 + }, }, '... got the right frozen class' ); my $foo2; - lives_ok { + is( exception { $foo2 = Foo->unpack($packed); - } '... unpacked okay'; + }, undef, '... unpacked okay'); isa_ok($foo2, 'Foo'); - + cmp_deeply( $foo2->pack, { @@ -78,14 +79,14 @@ BEGIN { float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, - object => { - __CLASS__ => 'Foo', - __DIGEST__ => re('[0-9a-f]+'), - number => 2 - }, + object => { + __CLASS__ => 'Foo', + __DIGEST__ => re('[0-9a-f]+'), + number => 2 + }, }, '... got the right frozen class' - ); + ); } { @@ -115,7 +116,12 @@ BEGIN { SKIP: { eval { require Digest::HMAC_SHA1 }; - skip join( " ", "no Digest::HMAC", ( $@ =~ /\@INC/ ? () : do { chomp(my $e = $@); "($e)" } ) ), 14 if $@; + if ($@) + { + my $message = join( " ", "no Digest::HMAC", ( $@ =~ /\@INC/ ? () : do { chomp(my $e = $@); "($e)" } ) ); + die $message if $ENV{AUTHOR_TESTING}; + skip $message, 15; + } local $::DEBUG = 1;