TAP::PARSER::RESULT::TEST(3perl)
π NAME π
TAP::Parser::Result::Test β the test result token β¨
This is a page from the Perl Programmers Reference Guide, section 3perl, and yes we are reading a manpage together, this is our thing now π«Ά
π VERSION π
Version 3.52 π
π¦ DESCRIPTION π¦
Okay so, plot twist: this is a subclass of TAP::Parser::Result π
A token of this class gets handed to you whenever a test line is encountered. That's it, that's the whole vibe. So if the parser bumps into something like:
1..1
ok 1 - woo hooo!
β¦you're getting a TAP::Parser::Result::Test object back, no cap π
π OVERRIDDEN METHODS π
This class is literally the workhorse of the whole TAP::Parser system, fr fr. Most TAP lines are gonna be test lines, so if $result->is_test is true, then bestie you have a bunch of methods at your disposal. Use them π
πΈ Instance Methods πΈ
β ok
my $ok = $result->ok;
Returns the literal text of the ok or not ok status. Literally the exact words, nothing more β¨
β number
my $test_number = $result->number;
Returns the number of the test β even if the original TAP output did not supply that number. So like, the parser is doing the math for you, iconic behavior π§
β description
my $description = $result->description;
Returns the description of the test, if any. Heads up: this is the portion after the test number but before the directive. Mind the boundaries bestie π
β directive
my $directive = $result->directive;
Returns either TODO or SKIP if either directive was present for a test line. If neither showed up, wellβ¦ don't expect a gift π
β explanation
my $explanation = $result->explanation;
If a test had either a TODO or SKIP directive, this method returns the accompanying explanation, if present.
not ok 17 - 'Pigs can fly' # TODO not enough acid
For the above line, the explanation is not enough acid. π (And yes, that is the actual example, I'm not making it up.)
β is_ok
if ( $result->is_ok ) { ... }
Returns a boolean value indicating whether or not the test passed.
β οΈ Remember that for TODO tests, the test always passes. And if the test is unplanned, this method will always return false. See is_unplanned below π
β is_actual_ok
if ( $result->is_actual_ok ) { ... }
Returns a boolean value indicating whether or not the test passed, regardless of its TODO status. No TODO goggles on this one π₯
β actual_passed
Deprecated. Please use is_actual_ok instead. She's retired, let her rest π
β todo_passed
if ( $test->todo_passed ) {
# test unexpectedly succeeded
}
If this is a TODO test and an ok line, this method returns true.
Otherwise, it will always return false β regardless of passing status on non-todo tests. (Yes, even then. Even if it passed. Still false. Sorry bestie π)
This is used to track which tests unexpectedly succeeded β¨
β todo_failed
# deprecated in favor of 'todo_passed'. This method was horribly misnamed.
This was a badly misnamed method. It indicates which TODO tests unexpectedly succeeded. It will now issue a warning and call todo_passed. It's giving "we fixed it but kept the name for the lore" π
β has_skip
if ( $result->has_skip ) { ... }
Returns a boolean value indicating whether or not this test has a SKIP directive π¦
β has_todo
if ( $result->has_todo ) { ... }
Returns a boolean value indicating whether or not this test has a TODO directive π
β as_string
print $result->as_string;
This method prints the test as a string. It will probably be similar, but not necessarily identical, to the original test line β so don't come for me if it's not a perfect twin π
Here's what changes:
- Directives are capitalized
- Some whitespace may be trimmed
- A test number will be added if it was not present in the original line
π‘ If you need the original text of the test line, use the raw method. That's the real one, no edits, periodt π
β is_unplanned
if ( $test->is_unplanned ) { ... }
$test->is_unplanned(1);
If a test number is greater than the number of planned tests, this method returns true. π¨
Unplanned tests will always return false for is_ok, regardless of whether or not the test has_todo. That's just how she is.
β οΈ Note that if tests have a trailing plan, it is not possible to set this property for unplanned tests, as we do not know it's unplanned until the plan is reached:
print <<'END';
ok 1
ok 2
1..1
END
Like, the plan shows up at the end, so we're all just finding out together π
And that's the whole page, bestie!! Every method, every caveat, every deprecated lil ghost. You ate this π
Signing off with the boring-but-necessary receipts: this was perl v5.44.0, dated 2026-10-17, from the TAP::Parser::Result::Test(3perl) page π Go forth and parse your TAP, you absolute icon πβ¨
π¦ 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