| 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::Tools::Class 3perl" |
| 58 |
.TH Test2::Tools::Class 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::Tools::Class \- Test2 implementation of the tools for testing classes. |
| 65 |
.SH DESCRIPTION |
| 66 |
.IX Header "DESCRIPTION" |
| 67 |
Test2 based tools for validating classes and objects. These are similar to |
| 68 |
some tools from Test::More, but they have a more consistent interface. |
| 69 |
.SH SYNOPSIS |
| 70 |
.IX Header "SYNOPSIS" |
| 71 |
.Vb 1 |
| 72 |
\& use Test2::Tools::Class; |
| 73 |
\& |
| 74 |
\& isa_ok($CLASS_OR_INSTANCE, $PARENT_CLASS1, $PARENT_CLASS2, ...); |
| 75 |
\& isa_ok($CLASS_OR_INSTANCE, [$PARENT_CLASS1, $PARENT_CLASS2, ...], "Test Name"); |
| 76 |
\& |
| 77 |
\& can_ok($CLASS_OR_INSTANCE, $METHOD1, $METHOD2, ...); |
| 78 |
\& can_ok($CLASS_OR_INSTANCE, [$METHOD1, $METHOD2, ...], "Test Name"); |
| 79 |
\& |
| 80 |
\& DOES_ok($CLASS_OR_INSTANCE, $ROLE1, $ROLE2, ...); |
| 81 |
\& DOES_ok($CLASS_OR_INSTANCE, [$ROLE1, $ROLE2, ...], "Test Name"); |
| 82 |
.Ve |
| 83 |
.SH EXPORTS |
| 84 |
.IX Header "EXPORTS" |
| 85 |
All subs are exported by default. |
| 86 |
.ie n .IP "can_ok($thing, @methods)" 4 |
| 87 |
.el .IP "can_ok($thing, \f(CW@methods\fR)" 4 |
| 88 |
.IX Item "can_ok($thing, @methods)" |
| 89 |
.PD 0 |
| 90 |
.ie n .IP "can_ok($thing, \e@methods, $test_name)" 4 |
| 91 |
.el .IP "can_ok($thing, \e@methods, \f(CW$test_name\fR)" 4 |
| 92 |
.IX Item "can_ok($thing, @methods, $test_name)" |
| 93 |
.PD |
| 94 |
This checks that \f(CW$thing\fR (either a class name, or a blessed instance) has the |
| 95 |
specified methods. |
| 96 |
.Sp |
| 97 |
If the second argument is an arrayref then it will be used as the list of |
| 98 |
methods leaving the third argument to be the test name. |
| 99 |
.ie n .IP "isa_ok($thing, @classes)" 4 |
| 100 |
.el .IP "isa_ok($thing, \f(CW@classes\fR)" 4 |
| 101 |
.IX Item "isa_ok($thing, @classes)" |
| 102 |
.PD 0 |
| 103 |
.ie n .IP "isa_ok($thing, \e@classes, $test_name)" 4 |
| 104 |
.el .IP "isa_ok($thing, \e@classes, \f(CW$test_name\fR)" 4 |
| 105 |
.IX Item "isa_ok($thing, @classes, $test_name)" |
| 106 |
.PD |
| 107 |
This checks that \f(CW$thing\fR (either a class name, or a blessed instance) is or |
| 108 |
subclasses the specified classes. |
| 109 |
.Sp |
| 110 |
If the second argument is an arrayref then it will be used as the list of |
| 111 |
classes leaving the third argument to be the test name. |
| 112 |
.ie n .IP "DOES_ok($thing, @roles)" 4 |
| 113 |
.el .IP "DOES_ok($thing, \f(CW@roles\fR)" 4 |
| 114 |
.IX Item "DOES_ok($thing, @roles)" |
| 115 |
.PD 0 |
| 116 |
.ie n .IP "DOES_ok($thing, \e@roles, $test_name)" 4 |
| 117 |
.el .IP "DOES_ok($thing, \e@roles, \f(CW$test_name\fR)" 4 |
| 118 |
.IX Item "DOES_ok($thing, @roles, $test_name)" |
| 119 |
.PD |
| 120 |
This checks that \f(CW$thing\fR (either a class name, or a blessed instance) does |
| 121 |
the specified roles. |
| 122 |
.Sp |
| 123 |
If the second argument is an arrayref then it will be used as the list of |
| 124 |
roles leaving the third argument to be the test name. |
| 125 |
.Sp |
| 126 |
\&\fBNote 1:\fR This uses the \f(CW\*(C`$class\->DOES(...)\*(C'\fR method, not the \f(CWdoes()\fR |
| 127 |
method Moose provides. |
| 128 |
.Sp |
| 129 |
\&\fBNote 2:\fR Not all perls have the \f(CWDOES()\fR method, if you use this on those |
| 130 |
perls the test will be skipped. |
| 131 |
.SH SOURCE |
| 132 |
.IX Header "SOURCE" |
| 133 |
The source code repository for Test2\-Suite can be found at |
| 134 |
\&\fIhttps://github.com/Test\-More/Test2\-Suite/\fR. |
| 135 |
.SH MAINTAINERS |
| 136 |
.IX Header "MAINTAINERS" |
| 137 |
.IP "Chad Granum <[email protected]>" 4 |
| 138 |
.IX Item "Chad Granum <[email protected]>" |
| 139 |
.SH AUTHORS |
| 140 |
.IX Header "AUTHORS" |
| 141 |
.PD 0 |
| 142 |
.IP "Chad Granum <[email protected]>" 4 |
| 143 |
.IX Item "Chad Granum <[email protected]>" |
| 144 |
.PD |
| 145 |
.SH COPYRIGHT |
| 146 |
.IX Header "COPYRIGHT" |
| 147 |
Copyright 2018 Chad Granum <[email protected]>. |
| 148 |
.PP |
| 149 |
This program is free software; you can redistribute it and/or |
| 150 |
modify it under the same terms as Perl itself. |
| 151 |
.PP |
| 152 |
See \fIhttp://dev.perl.org/licenses/\fR |