Debian Codegraph @

upstream/debian-unstable/man3/Test2::Compare::Base.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "Test2::Compare::Base 3perl"
58 .TH Test2::Compare::Base 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 Test2::Compare::Base \- Base class for comparison classes.
65 .SH DESCRIPTION
66 .IX Header "DESCRIPTION"
67 All comparison classes for Test2::Compare should inherit from this base class.
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 3
71 \& package Test2::Compare::MyCheck;
72 \& use strict;
73 \& use warnings;
74 \&
75 \& use base \*(AqTest2::Compare::Base\*(Aq;
76 \& use Test2::Util::HashBase qw/stuff/;
77 \&
78 \& sub name { \*(AqSTUFF\*(Aq }
79 \&
80 \& sub operator {
81 \& my $self = shift;
82 \& my ($got) = @_;
83 \& return \*(Aqeq\*(Aq;
84 \& }
85 \&
86 \& sub verify {
87 \& my $self = shift;
88 \& my $params = @_;
89 \&
90 \& # Always check if $got exists! This method must return false if no
91 \& # value at all was received.
92 \& return 0 unless $params{exists};
93 \&
94 \& my $got = $params{got};
95 \&
96 \& # Returns true if both values match. This includes undef, 0, and other
97 \& # false\-y values!
98 \& return $got eq $self\->stuff;
99 \& }
100 .Ve
101 .SH METHODS
102 .IX Header "METHODS"
103 Some of these must be overridden, others can be.
104 .ie n .IP "$dclass = $check\->delta_class" 4
105 .el .IP "\f(CW$dclass\fR = \f(CW$check\fR\->delta_class" 4
106 .IX Item "$dclass = $check->delta_class"
107 Returns the delta subclass that should be used. By default
108 Test2::Compare::Delta is used.
109 .ie n .IP "@deltas = $check\->deltas(id => $id, exists => $bool, got => $got, convert => \e&convert, seen => \e%seen)" 4
110 .el .IP "\f(CW@deltas\fR = \f(CW$check\fR\->deltas(id => \f(CW$id\fR, exists => \f(CW$bool\fR, got => \f(CW$got\fR, convert => \e&convert, seen => \e%seen)" 4
111 .IX Item "@deltas = $check->deltas(id => $id, exists => $bool, got => $got, convert => &convert, seen => %seen)"
112 Should return child deltas.
113 .ie n .IP "@lines = $check\->got_lines($got)" 4
114 .el .IP "\f(CW@lines\fR = \f(CW$check\fR\->got_lines($got)" 4
115 .IX Item "@lines = $check->got_lines($got)"
116 This is your chance to provide line numbers for errors in the \f(CW$got\fR
117 structure.
118 .ie n .IP "$op = $check\->\fBoperator()\fR" 4
119 .el .IP "\f(CW$op\fR = \f(CW$check\fR\->\fBoperator()\fR" 4
120 .IX Item "$op = $check->operator()"
121 .PD 0
122 .ie n .IP "$op = $check\->operator($got)" 4
123 .el .IP "\f(CW$op\fR = \f(CW$check\fR\->operator($got)" 4
124 .IX Item "$op = $check->operator($got)"
125 .PD
126 Returns the operator that was used to compare the check with the received data
127 in \f(CW$got\fR. If there was no value for got then there will be no arguments,
128 undef will only be an argument if undef was seen in \f(CW$got\fR. This is how you
129 can tell the difference between a missing value and an undefined one.
130 .ie n .IP "$bool = $check\->verify(id => $id, exists => $bool, got => $got, convert => \e&convert, seen => \e%seen)" 4
131 .el .IP "\f(CW$bool\fR = \f(CW$check\fR\->verify(id => \f(CW$id\fR, exists => \f(CW$bool\fR, got => \f(CW$got\fR, convert => \e&convert, seen => \e%seen)" 4
132 .IX Item "$bool = $check->verify(id => $id, exists => $bool, got => $got, convert => &convert, seen => %seen)"
133 Return true if there is a shallow match, that is both items are arrayrefs, both
134 items are the same string or same number, etc. This should not recurse, as deep
135 checks are done in \f(CW\*(C`$check\->deltas()\*(C'\fR.
136 .ie n .IP "$name = $check\->name" 4
137 .el .IP "\f(CW$name\fR = \f(CW$check\fR\->name" 4
138 .IX Item "$name = $check->name"
139 Get the name of the check.
140 .ie n .IP "$display = $check\->render" 4
141 .el .IP "\f(CW$display\fR = \f(CW$check\fR\->render" 4
142 .IX Item "$display = $check->render"
143 What should be displayed in a table for this check, usually the name or value.
144 .ie n .IP "$delta = $check\->run(id => $id, exists => $bool, got => $got, convert => \e&convert, seen => \e%seen)" 4
145 .el .IP "\f(CW$delta\fR = \f(CW$check\fR\->run(id => \f(CW$id\fR, exists => \f(CW$bool\fR, got => \f(CW$got\fR, convert => \e&convert, seen => \e%seen)" 4
146 .IX Item "$delta = $check->run(id => $id, exists => $bool, got => $got, convert => &convert, seen => %seen)"
147 This is where the checking is done, first a shallow check using
148 \&\f(CW\*(C`$check\->verify\*(C'\fR, then checking \f(CW\*(C`$check\->deltas()\*(C'\fR. \f(CW\*(C`\e%seen\*(C'\fR is used
149 to prevent cycles.
150 .SH SOURCE
151 .IX Header "SOURCE"
152 The source code repository for Test2\-Suite can be found at
153 \&\fIhttps://github.com/Test\-More/Test2\-Suite/\fR.
154 .SH MAINTAINERS
155 .IX Header "MAINTAINERS"
156 .IP "Chad Granum <[email protected]>" 4
157 .IX Item "Chad Granum <[email protected]>"
158 .SH AUTHORS
159 .IX Header "AUTHORS"
160 .PD 0
161 .IP "Chad Granum <[email protected]>" 4
162 .IX Item "Chad Granum <[email protected]>"
163 .PD
164 .SH COPYRIGHT
165 .IX Header "COPYRIGHT"
166 Copyright 2018 Chad Granum <[email protected]>.
167 .PP
168 This program is free software; you can redistribute it and/or
169 modify it under the same terms as Perl itself.
170 .PP
171 See \fIhttp://dev.perl.org/licenses/\fR