Test2::...:Generic(3)

πŸ“¦ version 1.302214, in opensuse-leap 16.0

🌸 NAME 🌸

Test2::Event::Generic β€” generic event type, no cap. This is the Test2::...:Generic(3) user-contributed Perl doc page, and it’s giving β€œcustom event but make it flexible” energy ✨

πŸ’– DESCRIPTION πŸ’–

This is a generic event that lets you customize all fields in the event API. It’s useful if you need a custom event that does not make sense as a published reusable event subclass. Literally the main character of β€œI need something custom and I don’t wanna make a whole subclass” vibes πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

use Test2::API qw/context/;

sub send_custom_fail {
    my $ctx = shift;

    $ctx->send_event('Generic', causes_fail => 1, summary => 'The sky is falling');

    $ctx->release;
}

send_custom_fail();

πŸ”₯ METHODS πŸ”₯

  • $e->facet_data($data) / $data = $e->facet_data β€” get or set the facet data (see Test2::Event). If no facet_data is set, then "Test2::Event->facet_data" will be called to produce facets from the other data. Obsessed with the fallback behavior, ngl.
  • $e->callback($hub) β€” call the custom callback if one is set; otherwise this does nothing. Lowkey chill like that.
  • $e->set_callback(sub { ... }) β€” set the custom callback. The custom callback must be a coderef. The first argument to your callback will be the event itself, the second will be the Test2::Hub that is using the callback. Bestie, respect the argument order 🫢
  • $bool = $e->causes_fail / $e->set_causes_fail($bool) β€” get/set the "causes_fail" attribute. This defaults to 0.
  • $bool = $e->diagnostics / $e->set_diagnostics($bool) β€” get/set the "diagnostics" attribute. This defaults to 0.
  • $bool_or_undef = $e->global / @bool_or_empty = $e->global / $e->set_global($bool_or_undef) β€” get/set the "diagnostics" attribute. This defaults to an empty list which is undef in scalar context. (Yes, that’s what it says here for this one β€” I’m keeping the lore exactly as written, iykyk πŸ’€)
  • $bool = $e->increments_count / $e->set_increments_count($bool) β€” get/set the "increments_count" attribute. This defaults to 0.
  • $bool = $e->no_display / $e->set_no_display($bool) β€” get/set the "no_display" attribute. This defaults to 0.
  • @plan = $e->sets_plan β€” get the plan if this event sets one. The plan is a list of up to 3 items: ($count, $directive, $reason). $count must be defined, the others may be undef, or may not exist at all. The way that little list is structured? Iconic.
  • $e->set_sets_plan(\@plan) β€” set the plan. You must pass in an arrayref with up to 3 elements. Fr fr, arrayref only πŸ’…
  • $summary = $e->summary / $e->set_summary($summary_or_undef) β€” get/set the summary. This will default to the event package 'Test2::Event::Generic'. You can set it to any value. Setting this to "undef" will reset it to the default. Cute little reset moment πŸŽ€
  • $int_or_undef = $e->terminate / @int_or_empty = $e->terminate / $e->set_terminate($int_or_undef) β€” this will get/set the "terminate" attribute. This defaults to undef in scalar context, or an empty list in list context. Setting this to undef will clear it completely. This must be set to a positive integer (0 or larger). Yes, β€œpositive integer (0 or larger)” is the exact wording β€” 0 counts, periodt.

πŸ’œ SOURCE πŸ’œ

The source code repository for Test2 can be found at https://github.com/Test-More/test-more/. Slay, open source πŸ’–

πŸ‘‘ 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 https://dev.perl.org/licenses/


okay that’s the whole page, bestie 🫢 β€” this cutie came from perl v5.42.0, dated 2025-07-28, and it lives at Test2::...:Generic(3). mwah πŸ’–

πŸ“¦ where this page comes from