-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test::Deep provides nice support for writing complex expectations that comes handy especially when system under test throws objects ``` throws_ok { code that should throw exception } all ( obj_isa ('Expected::Exception::Instance'), methods ( errcode => 400, errstr => re (qr/foo/), ) ), 'description' ; ``` Test::Deep is not dependency of Test::Exception, it is only recognized and used then assuming library is already loaded.
- Loading branch information
1 parent
d7484b9
commit 6f82a25
Showing
3 changed files
with
83 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More tests => 2; | ||
use Test::Deep; | ||
|
||
BEGIN { use_ok( 'Test::Exception' ) }; | ||
|
||
throws_ok | ||
{ die Local::Error->new( code => 404, message => 'Not Found' ) } | ||
all( | ||
obj_isa( 'Local::Error' ), | ||
methods( | ||
code => 404, | ||
message => re( qr/found/i ), | ||
), | ||
), | ||
'should recognize Test::Deep::Cmp expectation' | ||
; | ||
|
||
package | ||
Local::Error; | ||
|
||
sub new { | ||
my ( $class, %params ) = @_; | ||
|
||
bless \%params, $class; | ||
} | ||
|
||
sub code { | ||
$_[0]->{code}; | ||
} | ||
|
||
sub message { | ||
$_[0]->{message}; | ||
} | ||
|