File: exception_like.t

package info (click to toggle)
libtest-fatal-perl 0.012-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 152 kB
  • ctags: 5
  • sloc: perl: 214; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 488 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use strict;
use warnings FATAL => 'all';

use Test::More;
use Test::Fatal;
use Carp 'confess';

sub exception_like(&$;$)
{   
  my ($code, $pattern, $name) = @_;
  like( &exception($code), $pattern, $name );
}

exception_like(sub { confess 'blah blah' }, qr/foo/, 'foo seems to appear in the exception');

# the test only passes when we invert it
unlike(
    ( exception { confess 'blah blah' } || '' ),
    qr/foo/,
    'foo does NOT ACTUALLY appear in the exception',
);

done_testing;