TEST2::TOOLS::DEFER(3pm)

πŸŽ€ NAME πŸŽ€

okay so this is the manual page for Test2::Tools::Defer, chillin' in the Perl Programmers Reference Guide πŸ’– and its whole vibe is: write tests that get executed at a later time.

πŸ’… DESCRIPTION πŸ’…

Sometimes you need to test things BEFORE loading the necessary functions. This module literally lets you do that, bestie. You can write tests, and then have them run later, after Test2 is loaded.

You tell it what test function to run, and what arguments to give it. The function name and arguments will be stored to be executed later. When you're ready, run do_def() to kick them off once the functions are defined. slay ✨

🌸 SYNOPSIS 🌸

use strict;
use warnings;

use Test2::Tools::Defer;

BEGIN {
    def ok => (1, 'pass');
    def is => ('foo', 'foo', 'runs is');
    ...
}

use Test2::Tools::Basic;

do_def(); # Run the tests

# Declare some more tests to run later:
def ok => (1, "another pass");
...

do_def(); # run the new tests

done_testing;

πŸ¦‹ EXPORTS πŸ¦‹

  • def function => @args; β€” this stores the function name and the arguments to be run later. Important little note: each package has a separate store of tests to run. iykyk πŸ’«
  • do_def() β€” this runs all the stored tests. It also resets the list to be empty so you can add more tests to run even later. main character energy fr fr πŸ‘‘

πŸ”₯ SOURCE πŸ”₯

The source code repository for Test2-Suite can be found at https://github.com/Test-More/test-more/ ✨

πŸ‘‘ MAINTAINERS πŸ‘‘

  • Chad Granum <exodist@cpan.org>

πŸ’œ AUTHORS πŸ’œ

  • Chad Granum <exodist@cpan.org>

Copyright Chad Granum <exodist@cpan.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/


okay that's the whole page, bestie 🫢 it's rockin' perl v5.42.3, dated 2026-11-03, and its footer title is Test2::...s::Defer(3pm) β€” mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from