From 3d68caa7e8e3a88f8444a4c8a5b6cd5d6d30463d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 4 Apr 2011 18:51:15 +0200 Subject: Test::Exception -> Test::Fatal --- Build.PL | 5 +++-- t/20-app-raps2-password.t | 51 ++++++++++++++++++++++++----------------------- t/29-app-raps2.t | 2 +- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/Build.PL b/Build.PL index 9737b2a..25468a5 100644 --- a/Build.PL +++ b/Build.PL @@ -6,10 +6,11 @@ use Module::Build; my $build = Module::Build->new( build_requires => { - 'Test::More' => 0, + 'Test::Command' => 0, 'Test::Compile' => 0, + 'Test::Fatal' => 0, + 'Test::More' => 0, 'Test::Pod' => 0, - 'Test::Command' => 0, }, dist_name => 'raps2', dist_version_from => 'bin/raps2', diff --git a/t/20-app-raps2-password.t b/t/20-app-raps2-password.t index 56a6f4d..ae4f267 100644 --- a/t/20-app-raps2-password.t +++ b/t/20-app-raps2-password.t @@ -4,7 +4,7 @@ use warnings; use 5.010; use Test::More tests => 19; -use Test::Exception; +use Test::Fatal; my $pw; my $salt = 'abcdefghijklmnop'; @@ -12,24 +12,24 @@ my $pass = 'something'; use_ok('App::Raps2::Password'); -throws_ok( - sub { +like( + exception { App::Raps2::Password->new(); }, qr{incorrect salt length}, 'new() missing salt and passphrase' ); -throws_ok( - sub { +like( + exception { App::Raps2::Password->new(salt => $salt); }, qr{no passphrase given}, 'new() missing passphrase' ); -throws_ok( - sub { +like( + exception { App::Raps2::Password->new( salt => $salt, passphrase => q{} @@ -39,16 +39,16 @@ throws_ok( 'new() missing passphrase' ); -throws_ok( - sub { +like( + exception { App::Raps2::Password->new(passphrase => $pass); }, qr{incorrect salt length}, 'new() missing salt' ); -throws_ok( - sub { +like( + exception { App::Raps2::Password->new( passphrase => $pass, salt => 'abcdefghijklmno', @@ -58,8 +58,8 @@ throws_ok( 'new() salt one too short' ); -throws_ok( - sub { +like( + exception { App::Raps2::Password->new( passphrase => $pass, salt => $salt . 'z', @@ -90,8 +90,8 @@ is($pw->decrypt($pw->encrypt('foo')), 'foo', 'encrypt->decrypt okay'); ok($pw->verify('3lJRlaRuOGWv/z3g1DAOlcH.u9vS8Wm'), 'verify: verifies correct hash'); -throws_ok( - sub { +like( + exception { $pw->verify('3lJRlaRuOGWv/z3g1DAOlcH.u9vS8WM'); }, qr{Passwords did not match}, @@ -100,41 +100,42 @@ throws_ok( ok($pw->verify($pw->crypt('truth')), 'crypt->verify okay'); -throws_ok( - sub { +like( + exception { $pw->salt(); }, qr{incorrect salt length}, 'salt: No argument', ); -throws_ok( - sub { +like( + exception { $pw->salt(''); }, qr{incorrect salt length}, 'salt: Empty argument', ); -throws_ok( - sub { +like( + exception { $pw->salt('abcdefghijklmno'); }, qr{incorrect salt length}, 'salt: One too short', ); -throws_ok( - sub { +like( + exception { $pw->salt($salt . 'z'); }, qr{incorrect salt length}, 'salt: One too long', ); -lives_ok( - sub { +is( + exception { $pw->salt($salt); }, + undef, 'salt: Correct length', ); diff --git a/t/29-app-raps2.t b/t/29-app-raps2.t index c0baeac..cbb170e 100644 --- a/t/29-app-raps2.t +++ b/t/29-app-raps2.t @@ -4,7 +4,7 @@ use warnings; use 5.010; use Test::More tests => 4; -use Test::Exception; +use Test::Fatal; use_ok('App::Raps2'); -- cgit v1.2.3