X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F030_with_checksum.t;h=0715831195f0f01fe45841b86b42ecb282902c29;hb=1d4669291edf1495a90d5b110a6334b05ca1cc78;hp=98925004a6340c2ec61ee744c0f344bb30ccc606;hpb=b5f363acfcf077778dd4f3b59460a0cbb9e51400;p=gitmo%2FMooseX-Storage.git diff --git a/t/030_with_checksum.t b/t/030_with_checksum.t index 9892500..0715831 100644 --- a/t/030_with_checksum.t +++ b/t/030_with_checksum.t @@ -1,23 +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 $@; - eval "use JSON::Any"; - plan skip_all => "JSON::Any is required for this test" if $@; plan tests => 26; use_ok('MooseX::Storage'); } { - package Foo; use Moose; use MooseX::Storage; @@ -42,9 +41,9 @@ BEGIN { object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); - + my $packed = $foo->pack; - + cmp_deeply( $packed, { @@ -55,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, { @@ -80,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' - ); + ); } {