.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.13)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\" ========================================================================
.\"
.IX Title "Test2::Tools::Basic 3"
.TH Test2::Tools::Basic 3 "2019-05-18" "perl v5.10.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Test2::Tools::Basic \- Test2 implementation of the basic testing tools.
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This is a Test2 based implementation of the more basic tools originally
provided by Test::More. Not all Test::More tools are provided by this
package, only the basic/simple ones. Some tools have been modified for better
diagnostics capabilities.
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use Test2::Tools::Basic;
\&
\& ok($x, "simple test");
\&
\& if ($passing) {
\& pass(\*(Aqa passing test\*(Aq);
\& }
\& else {
\& fail(\*(Aqa failing test\*(Aq);
\& }
\&
\& diag "This is a diagnostics message on STDERR";
\& note "This is a diagnostics message on STDOUT";
\&
\& {
\& my $todo = todo "Reason for todo";
\& ok(0, "this test is todo");
\& }
\&
\& ok(1, "this test is not todo");
\&
\& todo "reason" => sub {
\& ok(0, "this test is todo");
\& };
\&
\& ok(1, "this test is not todo");
\&
\& SKIP: {
\& skip "This will wipe your drive";
\&
\& # This never gets run:
\& ok(!system(\*(Aqsudo rm \-rf /\*(Aq), "Wipe drive");
\& }
\&
\& done_testing;
.Ve
.SH "EXPORTS"
.IX Header "EXPORTS"
All subs are exported by default.
.SS "\s-1PLANNING\s0"
.IX Subsection "PLANNING"
.IP "plan($num)" 4
.IX Item "plan($num)"
.PD 0
.ie n .IP "plan('tests' => $num)" 4
.el .IP "plan('tests' => \f(CW$num\fR)" 4
.IX Item "plan('tests' => $num)"
.ie n .IP "plan('skip_all' => $reason)" 4
.el .IP "plan('skip_all' => \f(CW$reason\fR)" 4
.IX Item "plan('skip_all' => $reason)"
.PD
Set the number of tests that are expected. This must be done first or last,
never in the middle of testing.
.Sp
For legacy compatibility you can specify 'tests' as the first argument before
the number. You can also use this to skip all with the 'skip_all' prefix,
followed by a reason for skipping.
.IP "skip_all($reason)" 4
.IX Item "skip_all($reason)"
Set the plan to 0 with a reason, then exit true. This should be used before any
tests are run.
.IP "done_testing" 4
.IX Item "done_testing"
Used to mark the end of testing. This is a safe way to have a dynamic or
unknown number of tests.
.IP "bail_out($reason)" 4
.IX Item "bail_out($reason)"
Invoked when something has gone horribly wrong: stop everything, kill all threads and
processes, end the process with a false exit status.
.SS "\s-1ASSERTIONS\s0"
.IX Subsection "ASSERTIONS"
.IP "ok($bool)" 4
.IX Item "ok($bool)"
.PD 0
.ie n .IP "ok($bool, $name)" 4
.el .IP "ok($bool, \f(CW$name\fR)" 4
.IX Item "ok($bool, $name)"
.ie n .IP "ok($bool, $name, @diag)" 4
.el .IP "ok($bool, \f(CW$name\fR, \f(CW@diag\fR)" 4
.IX Item "ok($bool, $name, @diag)"
.PD
Simple assertion. If \f(CW$bool\fR is true the test passes, and if it is false the test
fails. The test name is optional, and all arguments after the name are added as
diagnostics message if and only if the test fails. If the test passes all the
diagnostics arguments will be ignored.
.IP "\fIpass()\fR" 4
.IX Item "pass()"
.PD 0
.IP "pass($name)" 4
.IX Item "pass($name)"
.PD
Fire off a passing test (a single Ok event). The name is optional
.IP "\fIfail()\fR" 4
.IX Item "fail()"
.PD 0
.IP "fail($name)" 4
.IX Item "fail($name)"
.ie n .IP "fail($name, @diag)" 4
.el .IP "fail($name, \f(CW@diag\fR)" 4
.IX Item "fail($name, @diag)"
.PD
Fire off a failing test (a single Ok event). The name and diagnostics are optional.
.SS "\s-1DIAGNOSTICS\s0"
.IX Subsection "DIAGNOSTICS"
.IP "diag(@messages)" 4
.IX Item "diag(@messages)"
Write diagnostics messages. All items in \f(CW@messages\fR will be joined into a
single string with no separator. When using \s-1TAP\s0, diagnostics are sent to \s-1STDERR\s0.
.IP "note(@messages)" 4
.IX Item "note(@messages)"
Write note-diagnostics messages. All items in \f(CW@messages\fR will be joined into
a single string with no separator. When using \s-1TAP\s0, notes are sent to \s-1STDOUT\s0.
.SS "\s-1META\s0"
.IX Subsection "META"
.ie n .IP "$todo = todo($reason)" 4
.el .IP "\f(CW$todo\fR = todo($reason)" 4
.IX Item "$todo = todo($reason)"
.PD 0
.ie n .IP "todo $reason => sub { ... }" 4
.el .IP "todo \f(CW$reason\fR => sub { ... }" 4
.IX Item "todo $reason => sub { ... }"
.PD
This is used to mark some results as \s-1TODO\s0. \s-1TODO\s0 means that the test may fail,
but will not cause the overall test suite to fail.
.Sp
There are two ways to use this. The first is to use a codeblock, and the \s-1TODO\s0 will
only apply to the codeblock.
.Sp
.Vb 1
\& ok(1, "before"); # Not TODO
\&
\& todo \*(Aqthis will fail\*(Aq => sub {
\& # This is TODO, as is any other test in this block.
\& ok(0, "blah");
\& };
\&
\& ok(1, "after"); # Not TODO
.Ve
.Sp
The other way is to use a scoped variable. \s-1TODO\s0 will end when the variable is
destroyed or set to undef.
.Sp
.Vb 1
\& ok(1, "before"); # Not TODO
\&
\& {
\& my $todo = todo \*(Aqthis will fail\*(Aq;
\&
\& # This is TODO, as is any other test in this block.
\& ok(0, "blah");
\& };
\&
\& ok(1, "after"); # Not TODO
.Ve
.Sp
This is the same thing, but without the \f(CW\*(C`{...}\*(C'\fR scope.
.Sp
.Vb 1
\& ok(1, "before"); # Not TODO
\&
\& my $todo = todo \*(Aqthis will fail\*(Aq;
\&
\& ok(0, "blah"); # TODO
\&
\& $todo = undef;
\&
\& ok(1, "after"); # Not TODO
.Ve
.IP "skip($why)" 4
.IX Item "skip($why)"
.PD 0
.ie n .IP "skip($why, $count)" 4
.el .IP "skip($why, \f(CW$count\fR)" 4
.IX Item "skip($why, $count)"
.PD
This is used to skip some tests. This requires you to wrap your tests in a
block labeled \f(CW\*(C`SKIP:\*(C'\fR. This is somewhat magical. If no \f(CW$count\fR is specified
then it will issue a single result. If you specify \f(CW$count\fR it will issue that
many results.
.Sp
.Vb 2
\& SKIP: {
\& skip "This will wipe your drive";
\&
\& # This never gets run:
\& ok(!system(\*(Aqsudo rm \-rf /\*(Aq), "Wipe drive");
\& }
.Ve
.SH "SOURCE"
.IX Header "SOURCE"
The source code repository for Test2\-Suite can be found at
\&\fIhttps://github.com/Test\-More/Test2\-Suite/\fR.
.SH "MAINTAINERS"
.IX Header "MAINTAINERS"
.IP "Chad Granum <exodist@cpan.org>" 4
.IX Item "Chad Granum <exodist@cpan.org>"
.SH "AUTHORS"
.IX Header "AUTHORS"
.PD 0
.IP "Chad Granum <exodist@cpan.org>" 4
.IX Item "Chad Granum <exodist@cpan.org>"
.PD
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright 2018 Chad Granum <exodist@cpan.org>.
.PP
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
.PP
See \fIhttp://dev.perl.org/licenses/\fR
Copyright 2K16 - 2K18 Indonesian Hacker Rulez