File: lives_ok.t

package info (click to toggle)
libtest-expander-perl 2.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 324 kB
  • sloc: perl: 457; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 716 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use strict;
use warnings
  FATAL    => qw( all ),
  NONFATAL => qw( deprecated exec internal malloc newline once portable redefine recursion uninitialized );

use Test::Builder::Tester tests => 2;

use Test::Expander;
use Test::Expander::Constants qw( $MSG_UNEXPECTED_EXCEPTION );

my $title = 'execution succeeds';
test_out( "ok 1 - $title" );
lives_ok( sub {}, $title );
test_test( $title );

$title = 'execution fails';
test_out( "ok 1 - $title" );
my $error     = 'DIE TEST';
my $mock_this = mock $CLASS => (
  override => [
    diag => sub { is( $_[ 0 ], $MSG_UNEXPECTED_EXCEPTION . $error . "\n", $title ) },
    ok   => sub ($;$@) { 1 },
  ],
);
lives_ok { die( $error . "\n" ) } $title;
test_test( $title );