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

our $VERSION = '1.302162';

BEGIN { require Test2::Event::Ok; our @ISA = qw(Test2::Event::Ok) }
use Test2::Util::HashBase qw{subevents buffered subtest_id subtest_uuid};

sub init {
    my $self = shift;
    $self-&gt;SUPER::init();
    $self-&gt;{+SUBEVENTS} ||= [];
    if ($self-&gt;{+EFFECTIVE_PASS}) {
        $_-&gt;set_effective_pass(1) for grep { $_-&gt;can('effective_pass') } @{$self-&gt;{+SUBEVENTS}};
    }
}

{
    no warnings 'redefine';

    sub set_subevents {
        my $self      = shift;
        my @subevents = @_;

        if ($self-&gt;{+EFFECTIVE_PASS}) {
            $_-&gt;set_effective_pass(1) for grep { $_-&gt;can('effective_pass') } @subevents;
        }

        $self-&gt;{+SUBEVENTS} = \@subevents;
    }

    sub set_effective_pass {
        my $self = shift;
        my ($pass) = @_;

        if ($pass) {
            $_-&gt;set_effective_pass(1) for grep { $_-&gt;can('effective_pass') } @{$self-&gt;{+SUBEVENTS}};
        }
        elsif ($self-&gt;{+EFFECTIVE_PASS} &amp;&amp; !$pass) {
            for my $s (grep { $_-&gt;can('effective_pass') } @{$self-&gt;{+SUBEVENTS}}) {
                $_-&gt;set_effective_pass(0) unless $s-&gt;can('todo') &amp;&amp; defined $s-&gt;todo;
            }
        }

        $self-&gt;{+EFFECTIVE_PASS} = $pass;
    }
}

sub summary {
    my $self = shift;

    my $name = $self-&gt;{+NAME} || "Nameless Subtest";

    my $todo = $self-&gt;{+TODO};
    if ($todo) {
        $name .= " (TODO: $todo)";
    }
    elsif (defined $todo) {
        $name .= " (TODO)";
    }

    return $name;
}

sub facet_data {
    my $self = shift;

    my $out = $self-&gt;SUPER::facet_data();

    $out-&gt;{parent} = {
        hid      =&gt; $self-&gt;subtest_id,
        children =&gt; [map {$_-&gt;facet_data} @{$self-&gt;{+SUBEVENTS}}],
        buffered =&gt; $self-&gt;{+BUFFERED},
    };

    return $out;
}

sub add_amnesty {
    my $self = shift;

    for my $am (@_) {
        $am = {%$am} if ref($am) ne 'ARRAY';
        $am = Test2::EventFacet::Amnesty-&gt;new($am);

        push @{$self-&gt;{+AMNESTY}} =&gt; $am;

        for my $e (@{$self-&gt;{+SUBEVENTS}}) {
            $e-&gt;add_amnesty($am-&gt;clone(inherited =&gt; 1));
        }
    }
}


1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Test2::Event::Subtest - Event for subtest types

=head1 DESCRIPTION

This class represents a subtest. This class is a subclass of
L&lt;Test2::Event::Ok&gt;.

=head1 ACCESSORS

This class inherits from L&lt;Test2::Event::Ok&gt;.

=over 4

=item $arrayref = $e-&gt;subevents

Returns the arrayref containing all the events from the subtest

=item $bool = $e-&gt;buffered

True if the subtest is buffered, that is all subevents render at once. If this
is false it means all subevents render as they are produced.

=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 2019 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>