<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Test2::API::InterceptResult::Event;
use strict;
use warnings;

our $VERSION = '1.302183';

use List::Util   qw/first/;
use Test2::Util  qw/pkg_to_file/;
use Scalar::Util qw/reftype blessed/;

use Storable qw/dclone/;
use Carp     qw/confess croak/;

use Test2::API::InterceptResult::Facet;
use Test2::API::InterceptResult::Hub;

use Test2::Util::HashBase qw{
    +causes_failure
    &lt;facet_data
    &lt;result_class
};

my %FACETS;
BEGIN {
    local $@;
    local *plugins;
    if (eval { require Module::Pluggable; 1 }) {
        Module::Pluggable-&gt;import(
            # We will replace the sub later
            require          =&gt; 1,
            on_require_error =&gt; sub { 1 },
            search_path      =&gt; ['Test2::EventFacet'],
            max_depth        =&gt; 3,
            min_depth        =&gt; 3,
        );

        for my $facet_type (__PACKAGE__-&gt;plugins) {
            my ($key, $list);
            eval {
                $key  = $facet_type-&gt;facet_key;
                $list = $facet_type-&gt;is_list;
            };
            next unless $key &amp;&amp; defined($list);

            $FACETS{$key} = {list =&gt; $list, class =&gt; $facet_type, loaded =&gt; 1};
        }
    }

    $FACETS{__GENERIC__} = {class =&gt; 'Test2::API::InterceptResult::Facet', loaded =&gt; 1};
}

sub facet_map { \%FACETS }

sub facet_info {
    my $facet = pop;

    return $FACETS{$facet} if exists $FACETS{$facet};

    my $mname = ucfirst(lc($facet));
    $mname =~ s/s$//;

    for my $name ($mname, "${mname}s") {
        my $file  = "Test2/EventFacet/$name.pm";
        my $class = "Test2::EventFacet::$name";

        local $@;
        my $ok = eval {
            require $file;

            my $key = $class-&gt;facet_key;
            my $list = $class-&gt;is_list;

            $FACETS{$key} = {list =&gt; $list, class =&gt; $class, loaded =&gt; 1};
            $FACETS{$facet} = $FACETS{$key} if $facet ne $key;

            1;
        };

        return $FACETS{$facet} if $ok &amp;&amp; $FACETS{$facet};
    }

    return $FACETS{$facet} = $FACETS{__GENERIC__};
}

sub init {
    my $self = shift;

    my $rc = $self-&gt;{+RESULT_CLASS} ||= 'Test2::API::InterceptResult';
    my $rc_file = pkg_to_file($rc);
    require($rc_file) unless $INC{$rc_file};

    my $fd = $self-&gt;{+FACET_DATA} ||= {};

    for my $facet (keys %$fd) {
        my $finfo = $self-&gt;facet_info($facet);
        my $is_list = $finfo-&gt;{list};
        next unless defined $is_list;

        my $type = reftype($fd-&gt;{$facet});

        if ($is_list) {
            confess "Facet '$facet' is a list facet, but got '$type' instead of an arrayref"
                unless $type eq 'ARRAY';

            for my $item (@{$fd-&gt;{$facet}}) {
                my $itype = reftype($item);
                next if $itype eq 'HASH';

                confess "Got item type '$itype' in list-facet '$facet', all items must be hashrefs";
            }
        }
        else {
            confess "Facet '$facet' is an only-one facet, but got '$type' instead of a hashref"
                unless $type eq 'HASH';
        }
    }
}

sub clone {
    my $self = shift;
    my $class = blessed($self);

    my %data = %$self;

    $data{+FACET_DATA} = dclone($data{+FACET_DATA});

    return bless(\%data, $class);
}

sub _facet_class {
    my $self = shift;
    my ($name) = @_;

    my $spec  = $self-&gt;facet_info($name);
    my $class = $spec-&gt;{class};
    unless ($spec-&gt;{loaded}) {
        my $file = pkg_to_file($class);
        require $file unless $INC{$file};
        $spec-&gt;{loaded} = 1;
    }

    return $class;
}

sub the_facet {
    my $self = shift;
    my ($name) = @_;

    return undef unless defined $self-&gt;{+FACET_DATA}-&gt;{$name};

    my $data = $self-&gt;{+FACET_DATA}-&gt;{$name};

    my $type = reftype($data) or confess "Facet '$name' has a value that is not a reference, this should not happen";

    return $self-&gt;_facet_class($name)-&gt;new(%{dclone($data)})
        if $type eq 'HASH';

    if ($type eq 'ARRAY') {
        return undef unless @$data;
        croak "'the_facet' called for facet '$name', but '$name' has '" . @$data . "' items" if @$data != 1;
        return $self-&gt;_facet_class($name)-&gt;new(%{dclone($data-&gt;[0])});
    }

    die "Invalid facet data type: $type";
}

sub facet {
    my $self = shift;
    my ($name) = @_;

    return () unless exists $self-&gt;{+FACET_DATA}-&gt;{$name};

    my $data = $self-&gt;{+FACET_DATA}-&gt;{$name};

    my $type = reftype($data) or confess "Facet '$name' has a value that is not a reference, this should not happen";

    my @out;
    @out = ($data)  if $type eq 'HASH';
    @out = (@$data) if $type eq 'ARRAY';

    my $class = $self-&gt;_facet_class($name);

    return map { $class-&gt;new(%{dclone($_)}) } @out;
}

sub causes_failure {
    my $self = shift;

    return $self-&gt;{+CAUSES_FAILURE}
        if exists $self-&gt;{+CAUSES_FAILURE};

    my $hub = Test2::API::InterceptResult::Hub-&gt;new();
    $hub-&gt;process($self);

    return $self-&gt;{+CAUSES_FAILURE} = ($hub-&gt;is_passing ? 0 : 1);
}

sub causes_fail { shift-&gt;causes_failure }

sub trace         { $_[0]-&gt;facet('trace') }
sub the_trace     { $_[0]-&gt;the_facet('trace') }
sub frame         { my $t = $_[0]-&gt;the_trace or return undef; $t-&gt;{frame} || undef }
sub trace_details { my $t = $_[0]-&gt;the_trace or return undef; $t-&gt;{details} || undef }
sub trace_package { my $f = $_[0]-&gt;frame or return undef; $f-&gt;[0] || undef }
sub trace_file    { my $f = $_[0]-&gt;frame or return undef; $f-&gt;[1] || undef }
sub trace_line    { my $f = $_[0]-&gt;frame or return undef; $f-&gt;[2] || undef }
sub trace_subname { my $f = $_[0]-&gt;frame or return undef; $f-&gt;[3] || undef }
sub trace_tool    { my $f = $_[0]-&gt;frame or return undef; $f-&gt;[3] || undef }

sub trace_signature { my $t = $_[0]-&gt;the_trace or return undef; Test2::EventFacet::Trace::signature($t) || undef }

sub brief {
    my $self = shift;

    my @try = qw{
        bailout_brief
        error_brief
        assert_brief
        plan_brief
    };

    for my $meth (@try) {
        my $got = $self-&gt;$meth or next;
        return $got;
    }

    return;
}

sub flatten {
    my $self = shift;
    my %params = @_;

    my $todo = {%{$self-&gt;{+FACET_DATA}}};
    delete $todo-&gt;{hubs};
    delete $todo-&gt;{meta};
    delete $todo-&gt;{trace};

    my $out = $self-&gt;summary;
    delete $out-&gt;{brief};
    delete $out-&gt;{facets};
    delete $out-&gt;{trace_tool};
    delete $out-&gt;{trace_details} unless defined($out-&gt;{trace_details});

    for my $tagged (grep { my $finfo = $self-&gt;facet_info($_); $finfo-&gt;{list} &amp;&amp; $finfo-&gt;{class}-&gt;can('tag') } keys %FACETS, keys %$todo) {
        my $set = delete $todo-&gt;{$tagged} or next;

        my $fd = $self-&gt;{+FACET_DATA};
        my $has_assert = $self-&gt;has_assert;
        my $has_parent = $self-&gt;has_subtest;
        my $has_fatal_error = $self-&gt;has_errors &amp;&amp; grep { $_-&gt;{fail} } $self-&gt;errors;

        next if $tagged eq 'amnesty' &amp;&amp; !($has_assert || $has_parent || $has_fatal_error);

        for my $item (@$set) {
            push @{$out-&gt;{lc($item-&gt;{tag})}} =&gt; $item-&gt;{fail} ? "FATAL: $item-&gt;{details}" : $item-&gt;{details};
        }
    }

    if (my $assert = delete $todo-&gt;{assert}) {
        $out-&gt;{pass} = $assert-&gt;{pass};
        $out-&gt;{name} = $assert-&gt;{details};
    }

    if (my $parent = delete $todo-&gt;{parent}) {
        delete $out-&gt;{subtest}-&gt;{bailed_out}  unless defined $out-&gt;{subtest}-&gt;{bailed_out};
        delete $out-&gt;{subtest}-&gt;{skip_reason} unless defined $out-&gt;{subtest}-&gt;{skip_reason};

        if (my $res = $self-&gt;subtest_result) {
            my $state = $res-&gt;state;
            delete $state-&gt;{$_} for grep { !defined($state-&gt;{$_}) } keys %$state;
            $out-&gt;{subtest} = $state;
            $out-&gt;{subevents} = $res-&gt;flatten(%params)
                if $params{include_subevents};
        }
    }

    if (my $control = delete $todo-&gt;{control}) {
        if ($control-&gt;{halt}) {
            $out-&gt;{bailed_out} = $control-&gt;{details} || 1;
        }
        elsif(defined $control-&gt;{details}) {
            $out-&gt;{control} = $control-&gt;{details};
        }
    }

    if (my $plan = delete $todo-&gt;{plan}) {
        $out-&gt;{plan} = $self-&gt;plan_brief;
        $out-&gt;{plan} =~ s/^PLAN\s*//;
    }

    for my $other (keys %$todo) {
        my $data = $todo-&gt;{$other} or next;

        if (reftype($data) eq 'ARRAY') {
            if (!$out-&gt;{$other} || reftype($out-&gt;{$other}) eq 'ARRAY') {
                for my $item (@$data) {
                    push @{$out-&gt;{$other}} =&gt; $item-&gt;{details} if defined $item-&gt;{details};
                }
            }
        }
        else {
            $out-&gt;{$other} = $data-&gt;{details} if defined($data-&gt;{details}) &amp;&amp; !defined($out-&gt;{$other});
        }
    }

    if (my $fields = $params{fields}) {
        $out = { map {exists($out-&gt;{$_}) ? ($_ =&gt; $out-&gt;{$_}) : ()} @$fields };
    }

    if (my $remove = $params{remove}) {
        delete $out-&gt;{$_} for @$remove;
    }

    return $out;
}

sub summary {
    my $self = shift;
    my %params = @_;

    my $out = {
        brief =&gt; $self-&gt;brief || '',

        causes_failure =&gt; $self-&gt;causes_failure,

        trace_line    =&gt; $self-&gt;trace_line,
        trace_file    =&gt; $self-&gt;trace_file,
        trace_tool    =&gt; $self-&gt;trace_subname,
        trace_details =&gt; $self-&gt;trace_details,

        facets =&gt; [ sort keys(%{$self-&gt;{+FACET_DATA}}) ],
    };

    if (my $fields = $params{fields}) {
        $out = { map {exists($out-&gt;{$_}) ? ($_ =&gt; $out-&gt;{$_}) : ()} @$fields };
    }

    if (my $remove = $params{remove}) {
        delete $out-&gt;{$_} for @$remove;
    }

    return $out;
}

sub has_assert { $_[0]-&gt;{+FACET_DATA}-&gt;{assert} ? 1 : 0 }
sub the_assert { $_[0]-&gt;the_facet('assert') }
sub assert     { $_[0]-&gt;facet('assert') }

sub assert_brief {
    my $self = shift;

    my $fd = $self-&gt;{+FACET_DATA};
    my $as = $fd-&gt;{assert} or return;
    my $am = $fd-&gt;{amnesty};

    my $out = $as-&gt;{pass} ? "PASS" : "FAIL";
    $out .= " with amnesty" if $am;
    return $out;
}

sub has_subtest { $_[0]-&gt;{+FACET_DATA}-&gt;{parent} ? 1 : 0 }
sub the_subtest { $_[0]-&gt;the_facet('parent') }
sub subtest     { $_[0]-&gt;facet('parent') }

sub subtest_result {
    my $self = shift;

    my $parent = $self-&gt;{+FACET_DATA}-&gt;{parent} or return;
    my $children = $parent-&gt;{children} || [];

    $children = $self-&gt;{+RESULT_CLASS}-&gt;new(@$children)-&gt;upgrade
        unless blessed($children) &amp;&amp; $children-&gt;isa($self-&gt;{+RESULT_CLASS});

    return $children;
}

sub has_bailout { $_[0]-&gt;bailout ? 1 : 0 }
sub the_bailout { my ($b) = $_[0]-&gt;bailout; $b }

sub bailout {
    my $self = shift;
    my $control = $self-&gt;{+FACET_DATA}-&gt;{control} or return;
    return $control if $control-&gt;{halt};
    return;
}

sub bailout_brief {
    my $self = shift;
    my $bo = $self-&gt;bailout or return;

    my $reason = $bo-&gt;{details} or return "BAILED OUT";
    return "BAILED OUT: $reason";
}

sub bailout_reason {
    my $self = shift;
    my $bo = $self-&gt;bailout or return;
    return $bo-&gt;{details} || '';
}

sub has_plan { $_[0]-&gt;{+FACET_DATA}-&gt;{plan} ? 1 : 0 }
sub the_plan { $_[0]-&gt;the_facet('plan') }
sub plan     { $_[0]-&gt;facet('plan') }

sub plan_brief {
    my $self = shift;

    my $plan = $self-&gt;{+FACET_DATA}-&gt;{plan} or return;

    my $base = $self-&gt;_plan_brief($plan);

    my $reason = $plan-&gt;{details} or return $base;
    return "$base: $reason";
}

sub _plan_brief {
    my $self = shift;
    my ($plan) = @_;

    return 'NO PLAN' if $plan-&gt;{none};
    return "SKIP ALL" if $plan-&gt;{skip} || !$plan-&gt;{count};
    return "PLAN $plan-&gt;{count}";
}

sub has_amnesty     { $_[0]-&gt;{+FACET_DATA}-&gt;{amnesty} ? 1 : 0 }
sub the_amnesty     { $_[0]-&gt;the_facet('amnesty') }
sub amnesty         { $_[0]-&gt;facet('amnesty') }
sub amnesty_reasons { map { $_-&gt;{details} } $_[0]-&gt;amnesty }

sub has_todos    { &amp;first(sub { uc($_-&gt;{tag}) eq 'TODO' }, $_[0]-&gt;amnesty) ? 1 : 0 }
sub todos        {       grep { uc($_-&gt;{tag}) eq 'TODO' }  $_[0]-&gt;amnesty          }
sub todo_reasons {       map  { $_-&gt;{details} || 'TODO' }  $_[0]-&gt;todos            }

sub has_skips    { &amp;first(sub { uc($_-&gt;{tag}) eq 'SKIP' }, $_[0]-&gt;amnesty) ? 1 : 0 }
sub skips        {       grep { uc($_-&gt;{tag}) eq 'SKIP' }  $_[0]-&gt;amnesty          }
sub skip_reasons {       map  { $_-&gt;{details} || 'SKIP' }  $_[0]-&gt;skips            }

my %TODO_OR_SKIP = (SKIP =&gt; 1, TODO =&gt; 1);
sub has_other_amnesty     { &amp;first( sub { !$TODO_OR_SKIP{uc($_-&gt;{tag})}            }, $_[0]-&gt;amnesty) ? 1 : 0 }
sub other_amnesty         {        grep { !$TODO_OR_SKIP{uc($_-&gt;{tag})}            }  $_[0]-&gt;amnesty          }
sub other_amnesty_reasons {        map  { $_-&gt;{details} ||  $_-&gt;{tag} || 'AMNESTY' }  $_[0]-&gt;other_amnesty    }

sub has_errors     { $_[0]-&gt;{+FACET_DATA}-&gt;{errors} ? 1 : 0 }
sub the_errors     { $_[0]-&gt;the_facet('errors') }
sub errors         { $_[0]-&gt;facet('errors') }
sub error_messages { map { $_-&gt;{details} || $_-&gt;{tag} || 'ERROR' } $_[0]-&gt;errors }

sub error_brief {
    my $self = shift;

    my $errors = $self-&gt;{+FACET_DATA}-&gt;{errors} or return;

    my $base = @$errors &gt; 1 ? "ERRORS" : "ERROR";

    return $base unless @$errors;

    my ($msg, @extra) = split /[\n\r]+/, $errors-&gt;[0]-&gt;{details};

    my $out = "$base: $msg";

    $out .= " [...]" if @extra || @$errors &gt; 1;

    return $out;
}

sub has_info      { $_[0]-&gt;{+FACET_DATA}-&gt;{info} ? 1 : 0 }
sub the_info      { $_[0]-&gt;the_facet('info') }
sub info          { $_[0]-&gt;facet('info') }
sub info_messages { map { $_-&gt;{details} } $_[0]-&gt;info }

sub has_diags { &amp;first(sub { uc($_-&gt;{tag}) eq 'DIAG' }, $_[0]-&gt;info) ? 1 : 0 }
sub diags         {   grep { uc($_-&gt;{tag}) eq 'DIAG' }  $_[0]-&gt;info          }
sub diag_messages {   map  { $_-&gt;{details} || 'DIAG' }  $_[0]-&gt;diags         }

sub has_notes { &amp;first(sub { uc($_-&gt;{tag}) eq 'NOTE' }, $_[0]-&gt;info) ? 1 : 0 }
sub notes         {   grep { uc($_-&gt;{tag}) eq 'NOTE' }  $_[0]-&gt;info          }
sub note_messages {   map  { $_-&gt;{details} || 'NOTE' }  $_[0]-&gt;notes         }

my %NOTE_OR_DIAG = (NOTE =&gt; 1, DIAG =&gt; 1);
sub has_other_info { &amp;first(sub { !$NOTE_OR_DIAG{uc($_-&gt;{tag})}         }, $_[0]-&gt;info) ? 1 : 0 }
sub other_info          {  grep { !$NOTE_OR_DIAG{uc($_-&gt;{tag})}         }  $_[0]-&gt;info          }
sub other_info_messages {  map  { $_-&gt;{details} ||  $_-&gt;{tag} || 'INFO' }  $_[0]-&gt;other_info    }

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Test2::API::InterceptResult::Event - Representation of an event for use in
testing other test tools.

=head1 DESCRIPTION

C&lt;intercept { ... }&gt; from L&lt;Test2::API&gt; returns an instance of
L&lt;Test2::API::InterceptResult&gt; which is a blessed arrayref of
L&lt;Test2::API::InterceptResult::Event&gt; objects.

This POD documents the methods of these events, which are mainly provided for
you to use when testing your test tools.

=head1 SYNOPSIS

    use Test2::V0;
    use Test2::API qw/intercept/;

    my $events = intercept {
        ok(1, "A passing assertion");
        plan(1);
    };

    # This will convert all events into instances of
    # Test2::API::InterceptResult::Event. Until we do this they are the
    # original Test::Event::* instances
    $events-&gt;upgrade(in_place =&gt; 1);

    # Now we can get individual events in this form
    my $assert = $events-&gt;[0];
    my $plan   = $events-&gt;[1];

    # Or we can operate on all events at once:
    my $flattened = $events-&gt;flatten;
    is(
        $flattened,
        [
          {
            causes_failure =&gt; 0,

            name =&gt; 'A passing assertion',
            pass =&gt; 1,

            trace_file =&gt; 'xxx.t',
            trace_line =&gt; 5,
          },
          {
            causes_failure =&gt; 0,

            plan =&gt; 1,

            trace_file =&gt; 'xxx.t',
            trace_line =&gt; 6,
          },
        ],
        "Flattened both events and returned an arrayref of the results
    );

=head1 METHODS

=head2 !!! IMPORTANT NOTES ON DESIGN !!!

Please pay attention to what these return, many return a scalar when
applicable or an empty list when not (as opposed to undef). Many also always
return a list of 0 or more items. Some always return a scalar. Note that none
of the methods care about context, their behavior is consistent regardless of
scalar, list, or void context.

This was done because this class was specifically designed to be used in a list
and generate more lists in bulk operations. Sometimes in a map you want nothing
to show up for the event, and you do not want an undef in its place. In general
single event instances are not going to be used alone, though that is allowed.

As a general rule any method prefixed with C&lt;the_&gt; implies the event should
have exactly 1 of the specified item, and and exception will be thrown if there
are 0, or more than 1 of the item.

=head2 ATTRIBUTES

=over 4

=item $hashref = $event-&gt;facet_data

This will return the facet data hashref, which is all Test2 cares about for any
given event.

=item $class = $event-&gt;result_class

This is normally L&lt;Test2::API::InterceptResult&gt;. This is set at construction so
that subtest results can be turned into instances of it on demand.

=back

=head2 DUPLICATION

=over 4

=item $copy = $event-&gt;clone

Create a deep copy of the event. Modifying either event will not effect the
other.

=back

=head2 CONDENSED MULTI-FACET DATA

=over 4

=item $bool = $event-&gt;causes_failure

=item $bool = $event-&gt;causes_fail

These are both aliases of the same functionality.

This will always return either a true value, or a false value. This never
returns a list.

This method may be relatively slow (still super fast) because it determines
pass or fail by creating an instance of L&lt;Test2::Hub&gt; and asking it to process
the event, and then asks the hub for its pass/fail state. This is slower than
bulding in logic to do the check, but it is more reliable as it will always
tell you what the hub thinks, so the logic will never be out of date relative
to the Test2 logic that actually cares.

=item STRING_OR_EMPTY_LIST = $event-&gt;brief

Not all events have a brief, some events are not rendered by the formatter,
others have no "brief" data worth seeing. When this is the case an empty list
is returned. This is done intentionally so it can be used in a map operation
without having C&lt;undef&gt; being included in the result.

When a brief can be generated it is always a single 1-line string, and is
returned as-is, not in a list.

Possible briefs:

    # From control facets
    "BAILED OUT"
    "BAILED OUT: $why"

    # From error facets
    "ERROR"
    "ERROR: $message"
    "ERROR: $partial_message [...]"
    "ERRORS: $first_error_message [...]"

    # From assert facets
    "PASS"
    "FAIL"
    "PASS with amnesty"
    "FAIL with amnesty"

    # From plan facets
    "PLAN $count"
    "NO PLAN"
    "SKIP ALL"
    "SKIP ALL: $why"

Note that only the first applicable brief is returned. This is essnetially a
poor-mans TAP that only includes facets that could (but not necessarily do)
cause a failure.

=item $hashref = $event-&gt;flatten

=item $hashref = $event-&gt;flatten(include_subevents =&gt; 1)

This ALWAYS returns a hashref. This puts all the most useful data for the most
interesting facets into a single hashref for easy validation.

If there are no meaningful facets this will return an empty hashref.

If given the 'include_subevents' parameter it will also include subtest data:

Here is a list of EVERY possible field. If a field is not applicable it will
not be present.

=over 4

=item always present

        causes_failure =&gt; 1,    # Always present

=item Present if the event has a trace facet

        trace_line    =&gt; 42,
        trace_file    =&gt; 'Foo/Bar.pm',
        trace_details =&gt; 'Extra trace details',    # usually not present

=item If an assertion is present

        pass =&gt; 0,
        name =&gt; "1 + 1 = 2, so math works",

=item If a plan is present:

        plan =&gt; $count_or_SKIP_ALL_or_NO_PLAN,

=item If amnesty facets are present

You get an array for each type that is present.

        todo =&gt; [    # Yes you could be under multiple todos, this will list them all.
            "I will fix this later",
            "I promise to fix these",
        ],

        skip =&gt; ["This will format the main drive, do not run"],

        ... =&gt; ["Other amnesty"]

=item If Info (note/diag) facets are present

You get an arrayref for any that are present, the key is not defined if they are not present.

        diag =&gt; [
            "Test failed at Foo/Bar.pm line 42",
            "You forgot to tie your boots",
        ],

        note =&gt; ["Your boots are red"],

        ...  =&gt; ["Other info"],

=item If error facets are present

Always an arrayref

        error =&gt; [
            "non fatal error (does not cause test failure, just an FYI",
            "FATAL: This is a fatal error (causes failure)",
        ],

        # Errors can have alternative tags, but in practice are always 'error',
        # listing this for completeness.
        ... =&gt; [ ... ]

=item Present if the event is a subtest

        subtest =&gt; {
            count      =&gt; 2,    # Number of assertions made
            failed     =&gt; 1,    # Number of test failures seen
            is_passing =&gt; 0,    # Boolean, true if the test would be passing
                                # after the events are processed.

            plan         =&gt; 2,  # Plan, either a number, undef, 'SKIP', or 'NO PLAN'
            follows_plan =&gt; 1,  # True if there is a plan and it was followed.
                                # False if the plan and assertions did not
                                # match, undef if no plan was present in the
                                # event list.

            bailed_out =&gt; "foo",    # if there was a bail-out in the
                                    # events in this will be a string explaining
                                    # why there was a bailout, if no reason was
                                    # given this will simply be set to true (1).

            skip_reason =&gt; "foo",   # If there was a skip_all this will give the
                                    # reason.
        },

if C&lt;&lt; (include_subtest =&gt; 1) &gt;&gt; was provided as a parameter then the following
will be included. This is the result of turning all subtest child events into
an L&lt;Test2::API::InterceptResult&gt; instance and calling the C&lt;flatten&gt; method on
it.

        subevents =&gt; Test2::API::InterceptResult-&gt;new(@child_events)-&gt;flatten(...),

=item If a bail-out is being requested

If no reason was given this will be set to 1.

        bailed_out =&gt; "reason",

=back

=item $hashref = $event-&gt;summary()

This returns a limited summary. See C&lt;flatten()&gt;, which is usually a better
option.

    {
        brief =&gt; $event-&gt;brief || '',

        causes_failure =&gt; $event-&gt;causes_failure,

        trace_line    =&gt; $event-&gt;trace_line,
        trace_file    =&gt; $event-&gt;trace_file,
        trace_tool    =&gt; $event-&gt;trace_subname,
        trace_details =&gt; $event-&gt;trace_details,

        facets =&gt; [ sort keys(%{$event-&gt;{+FACET_DATA}}) ],
    }

=back

=head2 DIRECT ARBITRARY FACET ACCESS

=over 4

=item @list_of_facets = $event-&gt;facet($name)

This always returns a list of 0 or more items. This fetches the facet instances
from the event. For facets like 'assert' this will always return 0 or 1
item. For events like 'info' (diags, notes) this will return 0 or more
instances, once for each instance of the facet.

These will be blessed into the proper L&lt;Test2::EventFacet&gt; subclass. If no
subclass can be found it will be blessed as an
L&lt;Test2::API::InterceptResult::Facet&gt; generic facet class.

=item $undef_or_facet = $event-&gt;the_facet($name)

If you know you will have exactly 1 instance of a facet you can call this.

If you are correct and there is exactly one instance of the facet it will
always return the hashref.

If there are 0 instances of the facet this will reutrn undef, not an empty
list.

If there are more than 1 instance this will throw an exception because your
assumption was incorrect.

=back

=head2 TRACE FACET

=over 4

=item @list_of_facets = $event-&gt;trace

TODO

=item $undef_or_hashref = $event-&gt;the_trace

This returns the trace hashref, or undef if it is not present.

=item $undef_or_arrayref = $event-&gt;frame

If a trace is present, and has a caller frame, this will be an arrayref:

    [$package, $file, $line, $subname]

If the trace is not present, or has no caller frame this will return undef.

=item $undef_or_string = $event-&gt;trace_details

This is usually undef, but occasionally has a string that overrides the
file/line number debugging a trace usually provides on test failure.

=item $undef_or_string = $event-&gt;trace_package

Same as C&lt;(caller())[0]&gt;, the first element of the trace frame.

Will be undef if not present.

=item $undef_or_string = $event-&gt;trace_file

Same as C&lt;(caller())[1]&gt;, the second element of the trace frame.

Will be undef if not present.

=item $undef_or_integer = $event-&gt;trace_line

Same as C&lt;(caller())[2]&gt;, the third element of the trace frame.

Will be undef if not present.

=item $undef_or_string = $event-&gt;trace_subname

=item $undef_or_string = $event-&gt;trace_tool

Aliases for the same thing

Same as C&lt;(caller($level))[4]&gt;, the fourth element of the trace frame.

Will be undef if not present.

=item $undef_or_string = $event-&gt;trace_signature

A string that is a unique signature for the trace. If a single context
generates multiple events they will all have the same signature. This can be
used to tie assertions and diagnostics sent as seperate events together after
the fact.

=back

=head2 ASSERT FACET

=over 4

=item $bool = $event-&gt;has_assert

Returns true if the event has an assert facet, false if it does not.

=item $undef_or_hashref = $event-&gt;the_assert

Returns the assert facet if present, undef if it is not.

=item @list_of_facets = $event-&gt;assert

TODO

=item EMPTY_LIST_OR_STRING = $event-&gt;assert_brief

Returns a string giving a brief of the assertion if an assertion is present.
Returns an empty list if no assertion is present.

=back

=head2 SUBTESTS (PARENT FACET)

=over 4

=item $bool = $event-&gt;has_subtest

True if a subetest is present in this event.

=item $undef_or_hashref = $event-&gt;the_subtest

Get the one subtest if present, otherwise undef.

=item @list_of_facets = $event-&gt;subtest

TODO

=item EMPTY_LIST_OR_OBJECT = $event-&gt;subtest_result

Returns an empty list if there is no subtest.

Get an instance of L&lt;Test2::API::InterceptResult&gt; representing the subtest.

=back

=head2 CONTROL FACET (BAILOUT, ENCODING)

=over 4

=item $bool = $event-&gt;has_bailout

True if there was a bailout

=item $undef_hashref = $event-&gt;the_bailout

Return the control facet if it requested a bailout.

=item EMPTY_LIST_OR_HASHREF = $event-&gt;bailout

Get a list of 0 or 1 hashrefs. The hashref will be the control facet if a
bail-out was requested.

=item EMPTY_LIST_OR_STRING = $event-&gt;bailout_brief

Get the brief of the balout if present.

=item EMPTY_LIST_OR_STRING = $event-&gt;bailout_reason

Get the reason for the bailout, an empty string if no reason was provided, or
an empty list if there was no bailout.

=back

=head2 PLAN FACET

TODO

=over 4

=item $bool = $event-&gt;has_plan

=item $undef_or_hashref = $event-&gt;the_plan

=item @list_if_hashrefs = $event-&gt;plan

=item EMPTY_LIST_OR_STRING $event-&gt;plan_brief

=back

=head2 AMNESTY FACET (TODO AND SKIP)

TODO

=over 4

=item $event-&gt;has_amnesty

=item $event-&gt;the_amnesty

=item $event-&gt;amnesty

=item $event-&gt;amnesty_reasons

=item $event-&gt;has_todos

=item $event-&gt;todos

=item $event-&gt;todo_reasons

=item $event-&gt;has_skips

=item $event-&gt;skips

=item $event-&gt;skip_reasons

=item $event-&gt;has_other_amnesty

=item $event-&gt;other_amnesty

=item $event-&gt;other_amnesty_reasons

=back

=head2 ERROR FACET (CAPTURED EXCEPTIONS)

TODO

=over 4

=item $event-&gt;has_errors

=item $event-&gt;the_errors

=item $event-&gt;errors

=item $event-&gt;error_messages

=item $event-&gt;error_brief

=back

=head2 INFO FACET (DIAG, NOTE)

TODO

=over 4

=item $event-&gt;has_info

=item $event-&gt;the_info

=item $event-&gt;info

=item $event-&gt;info_messages

=item $event-&gt;has_diags

=item $event-&gt;diags

=item $event-&gt;diag_messages

=item $event-&gt;has_notes

=item $event-&gt;notes

=item $event-&gt;note_messages

=item $event-&gt;has_other_info

=item $event-&gt;other_info

=item $event-&gt;other_info_messages

=back

=head1 SOURCE

The source code repository for Test2 can be found at
F&lt;http://github.com/Test-More/test-more/&gt;.

=head1 MAINTAINERS

=over 4

=item Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;

=back

=head1 AUTHORS

=over 4

=item Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;

=back

=head1 COPYRIGHT

Copyright 2020 Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;.

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

See F&lt;http://dev.perl.org/licenses/&gt;

=cut
</pre></body></html>