@@ -33,16 +33,17 @@ You can also provide a C<:skip-all> named argument instead of a test count,
33
33
to indicate that you want to skip all of the tests. Such a plan will
34
34
call L « C < exit > |/routine/exit» , unless used inside of a C < subtest > .
35
35
36
- plan :skip-all<These tests are only for Windows> unless $*DISTRO.is-win;
37
- plan 1;
38
- ok dir 'C:/'; # this won't get run on non-Windows
36
+ = for code :preamble<use Test;>
37
+ plan :skip-all<These tests are only for Windows> unless $*DISTRO.is-win;
38
+ plan 1;
39
+ ok dir 'C:/'; # this won't get run on non-Windows
39
40
40
41
If used in a C < subtest > , it will instead C < return > from that
41
42
C < subtest > 's L « C < Callable > |/type/Callable» . For that reason, to be able to
42
43
use C < :skip-all > inside a C < subtest > , you must use a C < sub > instead of a
43
44
regular block:
44
45
45
- = begin code
46
+ = begin code :preamble<use Test;>
46
47
plan 2;
47
48
subtest "Some Windows tests" => sub { # <-- note the `sub`; can't use bare block
48
49
plan :skip-all<We aren't on Windows> unless $*DISTRO.is-win;
@@ -634,7 +635,8 @@ Please note that you can only use the string form (for C<EVAL>) if you are not
634
635
referencing any symbols in the surrounding scope. If you are, you should
635
636
encapsulate your string with a block and an EVAL instead. For instance:
636
637
637
- throws-like { EVAL q[ fac("foo") ] }, X::TypeCheck::Argument;
638
+ = for code :preamble<use Test;>
639
+ throws-like { EVAL q[ fac("foo") ] }, X::TypeCheck::Argument;
638
640
639
641
= head2 sub fails-like
640
642
@@ -718,11 +720,13 @@ in which case one would C<skip> the test on other platforms.
718
720
Mark C < $count > tests as TODO, giving a C < $reason > as to why. By default
719
721
only one test will be marked TODO.
720
722
723
+ = begin code :preamble<use Test;>
721
724
sub my-custom-pi { 3 };
722
725
723
726
todo 'not yet precise enough'; # Mark the test as TODO.
724
727
is my-custom-pi(), pi, 'my-custom-pi'; # Run the test, but don't report
725
728
# failure in test harness.
729
+ = end code
726
730
727
731
The result from the test code above will be something like:
728
732
@@ -804,7 +808,7 @@ the test run and mark it as failed.
804
808
If you already know the tests will fail, you can bail out of the test run
805
809
using C < bail-out() > :
806
810
807
- = begin code
811
+ = begin code :preamble<use Test;>
808
812
my $has-db-connection;
809
813
...
810
814
$has-db-connection or bail-out 'Must have database connection for testing';
@@ -827,9 +831,9 @@ Defined as:
827
831
The C < pass > function marks a test as passed. C < flunk > marks a test as
828
832
B < not > passed. Both functions accept an optional test description.
829
833
830
- pass "Actually, this test has passed";
831
-
832
- flunk "But this one hasn't passed";
834
+ = for code :preamble<use Test;>
835
+ pass "Actually, this test has passed";
836
+ flunk "But this one hasn't passed";
833
837
834
838
Since these subroutines do not provide indication of what value was received
835
839
and what was expected, they should be used sparingly, such as when evaluating
@@ -851,7 +855,8 @@ provide information that the test itself did not provide. Or it can be used
851
855
to provide visual markers on how the testing of a test-file is progressing
852
856
(which can be important when doing stress testing).
853
857
854
- diag "Yay! The tests got to here!";
858
+ = for code :preamble<use Test;>
859
+ diag "Yay! The tests got to here!";
855
860
856
861
= end pod
857
862
0 commit comments