<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package App::Prove::State::Result::Test;

use strict;
use warnings;

=head1 NAME

App::Prove::State::Result::Test - Individual test results.

=head1 VERSION

Version 3.44

=cut

our $VERSION = '3.44';

=head1 DESCRIPTION

The C&lt;prove&gt; command supports a C&lt;--state&gt; option that instructs it to
store persistent state across runs. This module encapsulates the results for a
single test.

=head1 SYNOPSIS

    # Re-run failed tests
    $ prove --state=failed,save -rbv

=cut

my %methods = (
    name           =&gt; { method =&gt; 'name' },
    elapsed        =&gt; { method =&gt; 'elapsed', default =&gt; 0 },
    gen            =&gt; { method =&gt; 'generation', default =&gt; 1 },
    last_pass_time =&gt; { method =&gt; 'last_pass_time', default =&gt; undef },
    last_fail_time =&gt; { method =&gt; 'last_fail_time', default =&gt; undef },
    last_result    =&gt; { method =&gt; 'result', default =&gt; 0 },
    last_run_time  =&gt; { method =&gt; 'run_time', default =&gt; undef },
    last_todo      =&gt; { method =&gt; 'num_todo', default =&gt; 0 },
    mtime          =&gt; { method =&gt; 'mtime', default =&gt; undef },
    seq            =&gt; { method =&gt; 'sequence', default =&gt; 1 },
    total_passes   =&gt; { method =&gt; 'total_passes', default =&gt; 0 },
    total_failures =&gt; { method =&gt; 'total_failures', default =&gt; 0 },
    parser         =&gt; { method =&gt; 'parser' },
);

while ( my ( $key, $description ) = each %methods ) {
    my $default = $description-&gt;{default};
    no strict 'refs';
    *{ $description-&gt;{method} } = sub {
        my $self = shift;
        if (@_) {
            $self-&gt;{$key} = shift;
            return $self;
        }
        return $self-&gt;{$key} || $default;
    };
}

=head1 METHODS

=head2 Class Methods

=head3 C&lt;new&gt;

=cut

sub new {
    my ( $class, $arg_for ) = @_;
    $arg_for ||= {};
    bless $arg_for =&gt; $class;
}

=head2 Instance Methods

=head3 C&lt;name&gt;

The name of the test.  Usually a filename.

=head3 C&lt;elapsed&gt;

The total elapsed times the test took to run, in seconds from the epoch..

=head3 C&lt;generation&gt;

The number for the "generation" of the test run.  The first generation is 1
(one) and subsequent generations are 2, 3, etc.

=head3 C&lt;last_pass_time&gt;

The last time the test program passed, in seconds from the epoch.

Returns C&lt;undef&gt; if the program has never passed.

=head3 C&lt;last_fail_time&gt;

The last time the test suite failed, in seconds from the epoch.

Returns C&lt;undef&gt; if the program has never failed.

=head3 C&lt;mtime&gt;

Returns the mtime of the test, in seconds from the epoch.

=head3 C&lt;raw&gt;

Returns a hashref of raw test data, suitable for serialization by YAML.

=head3 C&lt;result&gt;

Currently, whether or not the test suite passed with no 'problems' (such as
TODO passed).

=head3 C&lt;run_time&gt;

The total time it took for the test to run, in seconds.  If C&lt;Time::HiRes&gt; is
available, it will have finer granularity.

=head3 C&lt;num_todo&gt;

The number of tests with TODO directives.

=head3 C&lt;sequence&gt;

The order in which this test was run for the given test suite result. 

=head3 C&lt;total_passes&gt;

The number of times the test has passed.

=head3 C&lt;total_failures&gt;

The number of times the test has failed.

=head3 C&lt;parser&gt;

The underlying parser object.  This is useful if you need the full
information for the test program.

=cut

sub raw {
    my $self = shift;
    my %raw  = %$self;

    # this is backwards-compatibility hack and is not guaranteed.
    delete $raw{name};
    delete $raw{parser};
    return \%raw;
}

1;
</pre></body></html>