Test2::...e::Base(3pm)
π¦ Test2::...e::Base(3pm) β Perl Programmers Reference Guide π¦
π NAME π
Test2::Compare::Base β base class for comparison classes. That's the whole name, no cap.
πΈ DESCRIPTION πΈ
All comparison classes for Test2::Compare should inherit from this base class. It's giving βeveryone's parentβ energy, and honestly? iconic.
β¨ SYNOPSIS β¨
Okay so here's the exact starter code from the page β copy it character for character, bestie, because code is sacred:
package Test2::Compare::MyCheck;
use strict;
use warnings;
use base 'Test2::Compare::Base';
use Test2::Util::HashBase qw/stuff/;
sub name { 'STUFF' }
sub operator {
my $self = shift;
my ($got) = @_;
return 'eq';
}
sub verify {
my $self = shift;
my $params = @_;
# Always check if $got exists! This method must return false if no
# value at all was received.
return 0 unless $params{exists};
my $got = $params{got};
# Returns true if both values match. This includes undef, 0, and other
# false-y values!
return $got eq $self->stuff;
}
π METHODS π
Some of these must be overridden, others can be. Here's the whole method menu:
$dclass = $check->delta_classβ returns the delta subclass that should be used. By defaultTest2::Compare::Deltais used. default queen.@deltas = $check->deltas(id => $id, exists => $bool, got => $got, convert => \&convert, seen => \%seen)β should return child deltas. yes, child deltas, plural.@lines = $check->got_lines($got)β this is your chance to provide line numbers for errors in the$gotstructure. line numbers for the win.$op = $check->operator()/$op = $check->operator($got)β returns the operator that was used to compare the check with the received data in$got. If there was no value for got then there will be no arguments;undefwill only be an argument ifundefwas seen in$got. This is how you can tell the difference between a missing value and an undefined one. the missing-vs-undef detective work, iykyk.$bool = $check->verify(id => $id, exists => $bool, got => $got, convert => \&convert, seen => \%seen)β return true if there is a shallow match, that is both items are arrayrefs, both items are the same string or same number, etc. This should not recurse, as deep checks are done in"$check->deltas()". shallow only β do not go deep here, bestie.$name = $check->nameβ get the name of the check. name check, slay.$display = $check->renderβ what should be displayed in a table for this check, usually the name or value. table display moment.$delta = $check->run(id => $id, exists => $bool, got => $got, convert => \&convert, seen => \%seen)β this is where the checking is done: first a shallow check using"$check->verify", then checking"$check->deltas()"."\%seen"is used to prevent cycles. final boss method energy.
π 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> holding it down.
π«Ά AUTHORS π«Ά
Chad Granum <exodist@cpan.org> same icon, same legend.
π COPYRIGHT π
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 bestie, that's the whole page π
this manual page is Test2::...e::Base(3pm), served up by perl v5.42.3 and dated 2026-11-03. bye, ily π¦β¨
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms