TAP::P...actory(3perl)
πΈ NAME πΈ
TAP::Parser::ResultFactory β the factory for creating TAP::Parser output objects, bestie. It's TAP::P...actory(3perl) from the Perl Programmers Reference Guide, and she's here to hand out result objects like party favors π
β¨ SYNOPSIS β¨
use TAP::Parser::ResultFactory;
my $token = {...};
my $factory = TAP::Parser::ResultFactory->new;
my $result = $factory->make_result( $token );
Like. That's it. That's the whole vibe. π¦
π VERSION π
Version 3.52. Slay. π
π¦ DESCRIPTION π¦
Okay so this is a simple factory class, and what it does is return a TAP::Parser::Result subclass that represents the current little bit of test data from TAP β and usually that's just a single line, no cap. π
It's used primarily by TAP::Parser::Grammar, which is giving main character energy in this whole setup tbh. And unless you're subclassing, you probably won't need to use this module directly β like, she's the backstage crew, not the performer. But she ate regardless. π
π METHODS π
π«Ά Class Methods π«Ά
new
Creates a new factory class. new said "I'm baby" π
Note: you currently don't need to instantiate a factory in order to use it. Fr fr. The class methods just work. It's giving low-maintenance queen.
make_result
Returns an instance the appropriate class for the test token passed in. (Yes, that's the original wording, keep up π) Like, you give her a token, she gives you back the right result class:
my $result = TAP::Parser::ResultFactory->make_result($token);
Can also be called as an instance method β so both flavors are valid, and she's flexible like that. π§
class_for
Takes one argument: $type. Returns the class for this $type, or croaks with an error. So if you hand her a type she doesn't recognize? She will literally croak at you. Not a drill. π
register_type
Takes two arguments: $type, $class.
This lets you override an existing type with your own custom type, or register a completely new type, eg:
# create a custom result type:
package MyResult;
use strict;
use base 'TAP::Parser::Result';
# register with the factory:
TAP::Parser::ResultFactory->register_type( 'my_type' => __PACKAGE__ );
# use it:
my $r = TAP::Parser::ResultFactory->( { type => 'my_type' } );
Your custom type should then be picked up automatically by the TAP::Parser. No extra steps, she just knows. β¨
π SUBCLASSING π
Please see "SUBCLASSING" in TAP::Parser for a subclassing overview β go read that, I'll wait. π
There are a few things to bear in mind when creating your own "ResultFactory":
- The factory itself is never instantiated (this may change in the future). This means that
"_initialize"is never called. So don't go looking for it, she's not coming. π "TAP::Parser::Result->new"is never called,$tokensare reblessed. This will change in a future version! So like, heads up for future-you. β οΈTAP::Parser::Resultsubclasses will register themselves withTAP::Parser::ResultFactorydirectly:
package MyFooResult;
TAP::Parser::ResultFactory->register_type( foo => __PACKAGE__ );
Of course, it's up to you to decide whether or not to ignore them. Your call, your rules, your kingdom. π
π Example π
package MyResultFactory;
use strict;
use MyResult;
use base 'TAP::Parser::ResultFactory';
# force all results to be 'MyResult'
sub class_for {
return 'MyResult';
}
1;
Look at her. Forcing every single result to be MyResult. That's main character energy and honestly? Respect. π
π SEE ALSO π
TAP::ParserTAP::Parser::ResultTAP::Parser::Grammar
Okay bestie, that's the whole page β every flag, every method, every caveat, not one crumb left behind. π«Ά This was TAP::P...actory(3perl) from perl v5.44.0, dated 2026-10-17. Mwah, periodt. π
β¨
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms