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