Current File : //usr/local/share/man/man3/POE::Test::Sequence.3pm |
.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "POE::Test::Sequence 3"
.TH POE::Test::Sequence 3 "2022-03-23" "perl v5.26.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
POE::Test::Sequence \- POE test helper to verify a sequence of events
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& Sorry, there isn\*(Aqt a synopsis at this time.
\&
\& However, see t/90_regression/whjackson\-followtail.t in POE\*(Aqs test
\& suite for a full example.
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
POE::Test::Sequence is a test helper that abstracts a lot of the
tedious trickery needed to verify the relative ordering of events.
.PP
With this module, one can test the sequence of events without
necessarily relying on specific times elapsing between them.
.SS "create_generic_session"
.IX Subsection "create_generic_session"
The \fBcreate_generic_session()\fR method creates a POE::Session that routes
all vents through the POE::Test::Sequence object. It returns the
POE::Session object, but the test program does not need to store it
anywhere. In fact, it's recommended not to do that without
understanding the implications.
.PP
The implications can be found in the documentation for POE::Kernel and
POE::Session.
.PP
An example of \fBcreate_generic_session()\fR can be found in
\&\s-1POE\s0's t/90_regression/leolo\-alarm\-adjust.t test program.
.SS "new"
.IX Subsection "new"
Create a new sequence object. Takes named parameter pairs, currently
just \*(L"sequence\*(R", which references an array of steps. Each step is an
array reference containing the expected event, a required parameter to
that event, and a code reference for the optional next step to take
after testing for that event.
.PP
.Vb 6
\& my $sequence = POE::Test::Sequence\->new(
\& sequence => [
\& [ got_idle_event => 0, sub { append_to_log("text") } ],
\& ...,
\& ]
\& );
.Ve
.PP
\&\fBnext()\fR uses the first two step elements to verify that steps are
occurring in the order in which they should. The third element is
returned by \fBnext()\fR and is suitable for use as a \fBgoto()\fR target. See
the \fBnext()\fR method for more details.
.SS "next"
.IX Subsection "next"
The \fBnext()\fR method requires an event name and a scalar parameter.
These are compared to the first two elements of the next sequence step
to make sure events are happening in the order in which they should.
.PP
.Vb 3
\& sub handle_start_event {
\& goto $sequence\->next("got_start_event", 0);
\& }
.Ve
.SS "test_count"
.IX Subsection "test_count"
\&\fBtest_count()\fR returns the number of test steps in the sequence object.
It's intended to be used for test planning.
.PP
.Vb 3
\& use Test::More;
\& my $sequence = POE::Test::Sequence\->new( ... );
\& plan tests => $sequence\->test_count();
.Ve
.SH "BUGS"
.IX Header "BUGS"
\&\fBcreate_generic_session()\fR is hard-coded to pass only the event name and
the numeric value 0 to \fBnext()\fR. This is fine for only the most generic
sequences.
.SH "AUTHORS & LICENSING"
.IX Header "AUTHORS & LICENSING"
Please see \s-1POE\s0 for more information about authors, contributors,
and \s-1POE\s0's licensing.