POE::T...equence(3pm)
β¨ NAME β¨
POE::Test::Sequence β a POE test helper that verifies a sequence of events π (it lives in the POE::Test::Sequence man page, aka POE::T...equence(3pm), User Contributed Perl Documentation, iykyk)
πΈ SYNOPSIS πΈ
Sorry, there isn't a synopsis at this time. π
But bestie, don't panic β see t/90_regression/whjackson-followtail.t in POE's test suite for a full example. Go look, it ate. π
π¦ DESCRIPTION π¦
POE::Test::Sequence is a test helper that abstracts a lot of the tedious trickery needed to verify the relative ordering of events.
With this module, one can test the sequence of events without necessarily relying on specific times elapsing between them. No waiting around, no clock-watching, we just vibe check the order. β¨
π create_generic_session π
The create_generic_session() method creates a POE::Session that routes all vents through the POE::Test::Sequence object. (Yes, the original says "vents" β we love a typo moment, it's giving iconic π.)
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. π
The implications can be found in the documentation for POE::Kernel and POE::Session. Go read them, bestie, it's giving required reading. π
An example of create_generic_session() can be found in POE's t/90_regression/leolo-alarm-adjust.t test program. π«Ά
π new π
Create a new sequence object. Takes named parameter pairs, currently just "sequence", 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.
my $sequence = POE::Test::Sequence->new(
sequence => [
[ got_idle_event => 0, sub { append_to_log("text") } ],
...,
]
);
next() 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 next() and is suitable for use as a goto() target. See the next() method for more details. π
π next π
The next() 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. Lowkey the whole point of this module. π
sub handle_start_event {
goto $sequence->next("got_start_event", 0);
}
β test_count β
test_count() returns the number of test steps in the sequence object. It's intended to be used for test planning. ποΈ
use Test::More;
my $sequence = POE::Test::Sequence->new( ... );
plan tests => $sequence->test_count();
π BUGS π
create_generic_session() is hard-coded to pass only the event name and the numeric value 0 to next(). This is fine for only the most generic sequences. So if your sequence is doing the most, just know it's not gonna cover you, fr fr. π
π AUTHORS & LICENSING π
Please see POE for more information about authors, contributors, and POE's licensing. π«Ά
okay that's the whole page, you're officially a POE::Test::Sequence girlie now πβ¨
This little manual moment came to you courtesy of perl v5.34.0, dated 2022-03-25, and yes it's POE::T...equence(3pm) β slay, bye bestie! ππ¦
π¦ where this page comes from
- debian bookworm: libpoe-perl 2:1.3700-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libpoe-perl 2:1.3700-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libpoe-perl 2:1.3700-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libpoe-perl 2:1.3700-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms