summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple/t/subtest/die.t
blob: 3d53abf6ccbb7091b9e7934178330c9b86113b5d (plain)
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
27
28
29
30
#!/usr/bin/perl -w

# What happens when a subtest dies?

use lib 't/lib';

use strict;
use Test::Builder;
use Test::Builder::NoOutput;

my $Test = Test::Builder->new;

{
    my $tb = Test::Builder::NoOutput->create;

    $tb->ok(1);

    $Test->ok( !eval {
        $tb->subtest("death" => sub {
            die "Death in the subtest";
        });
        1;
    });
    $Test->like( $@, qr/^Death in the subtest at \Q$0\E line /);

    $Test->ok( !$tb->parent, "the parent object is restored after a die" );
}


$Test->done_testing();