summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/cpan/Test-Simple/t/Test2/modules/Event/Bail.t
blob: f245b205d98f09652902cb404f97a5aa81e80c54 (plain) (blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use strict;
use warnings;
use Test2::Tools::Tiny;
use Test2::Event::Bail;
use Test2::EventFacet::Trace;

my $bail = Test2::Event::Bail->new(
    trace => Test2::EventFacet::Trace->new(frame => ['foo', 'foo.t', 42]),
    reason => 'evil',
);

ok($bail->causes_fail, "bailout always causes fail.");

is($bail->terminate, 255, "Bail will cause the test to exit.");
is($bail->global, 1, "Bail is global, everything should bail");

is($bail->summary, "Bail out!  evil", "Summary includes reason");
$bail->set_reason("");
is($bail->summary, "Bail out!", "Summary has no reason");

ok($bail->diagnostics, "Bail events are counted as diagnostics");

is_deeply(
    $bail->facet_data,
    {
        about => {
            package => 'Test2::Event::Bail',
            eid     => $bail->eid,
        },
        control => {
            global    => 1,
            terminate => 255,
            details   => '',
            halt      => 1
        },
        trace => {
            frame => [
                'foo',
                'foo.t',
                '42',
            ],
            pid => $$,
            tid => 0
        },
    },
    "Got facet data",
);

$bail->set_reason('uhg');
is_deeply(
    $bail->facet_data,
    {
        about => {
            package => 'Test2::Event::Bail',
            eid     => $bail->eid,
        },
        control => {
            global    => 1,
            terminate => 255,
            details   => 'uhg',
            halt      => 1
        },
        trace => {
            frame => [
                'foo',
                'foo.t',
                '42',
            ],
            pid => $$,
            tid => 0
        },
    },
    "Got facet data with reason",
);

done_testing;