Skip to content

Commit 9d23c2b

Browse files
committed
Some reflow, refs #2683
1 parent 202577d commit 9d23c2b

File tree

1 file changed

+44
-39
lines changed

1 file changed

+44
-39
lines changed

doc/Type/Test.pod6

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ Specify that testing has finished. Use this function when you don't
7171
have a C<plan> with the number of tests to run. A C<plan> is not
7272
required when using C<done-testing>.
7373
74-
It's recommended that the C<done-testing> function be removed and replaced
75-
with a C<plan> function when all tests are finalized. Use of C<plan> can help
76-
detect test failures otherwise not reported because tests were accidentally skipped
77-
due to bugs in the tests or bugs in the compiler. For example:
74+
It's recommended that the C<done-testing> function be removed and replaced with
75+
a C<plan> function when all tests are finalized. Use of C<plan> can help detect
76+
test failures otherwise not reported because tests were accidentally skipped due
77+
to bugs in the tests or bugs in the compiler. For example:
7878
7979
sub do-stuff {@};
8080
use Test;
@@ -85,8 +85,9 @@ due to bugs in the tests or bugs in the compiler. For example:
8585
1..0
8686
8787
The above example is where a C<done-testing> fails. C<do-stuff()> returned
88-
nothing and tested nothing, even though it should've returned results to test. But
89-
the test suite doesn't know how many tests were meant to be run, so it passes.
88+
nothing and tested nothing, even though it should've returned results to test.
89+
But the test suite doesn't know how many tests were meant to be run, so it
90+
passes.
9091
9192
Adding C<plan> gives a true picture of the test:
9293
@@ -166,9 +167,10 @@ L«C<is-deeply> routine|/language/testing#index-entry-is-deeply-is-deeply($value
166167
my Int $a;
167168
is $a, Int, 'The variable $a is an unassigned Int';
168169
169-
B<Note:> if I<only> whitespace differs between the values, C<is()> will output failure
170-
message differently, to show the whitespace in each values. For example, in the
171-
output below, the second test shows the literal C<\t> in the C<got:> line:
170+
B<Note:> if I<only> whitespace differs between the values, C<is()> will output
171+
failure message differently, to show the whitespace in each values. For example,
172+
in the output below, the second test shows the literal C<\t> in the C<got:>
173+
line:
172174
173175
=for code
174176
is "foo\tbar", "foo\tbaz"; # expected: 'foo baz'␤# got: 'foo bar'
@@ -512,7 +514,7 @@ sub saruman(Bool :$ents-destroy-isengard) {
512514
dies-ok { saruman(ents-destroy-isengard => True) }, "Saruman dies";
513515
=end code
514516
515-
=head2 lives-ok
517+
=head2 sub lives-ok
516518
517519
Defined as:
518520
@@ -531,7 +533,7 @@ sub frodo(Bool :$destroys-ring) {
531533
lives-ok { frodo(destroys-ring => True) }, "Frodo survives";
532534
=end code
533535
534-
=head2 eval-dies-ok
536+
=head2 sub eval-dies-ok
535537
536538
Defined as:
537539
@@ -548,7 +550,7 @@ eval-dies-ok q[my $joffrey = "nasty";
548550
"Ned Stark dies";
549551
=end code
550552
551-
=head2 eval-lives-ok
553+
=head2 sub eval-lives-ok
552554
553555
Defined as:
554556
@@ -565,7 +567,7 @@ eval-lives-ok q[my $daenerys-burns = False;
565567
"Dany is blood of the dragon";
566568
=end code
567569
568-
=head2 throws-like
570+
=head2 sub throws-like
569571
570572
Defined as:
571573
@@ -593,38 +595,41 @@ positional argument.
593595
The routine makes L<Failures|/type/Failure> fatal. If you wish to avoid that,
594596
use L«C<no fatal> pragma|/language/pragmas#index-entry-fatal-fatal» and ensure
595597
the tested code does not sink the possible L<Failures|/type/Failure>. If you
596-
wish to test that the code returns a L<Failure|/type/Failure> instead of throwing, use
597-
C<fails-like> routine instead.
598+
wish to test that the code returns a L<Failure|/type/Failure> instead of
599+
throwing, use C<fails-like> routine instead.
598600
599-
sub fails-not-throws { +"a" }
600-
# test passes, even though it's just a Failure and would not always throw:
601-
throws-like { fails-not-throws }, Exception;
601+
=begin code
602+
sub fails-not-throws { +"a" }
603+
# test passes, even though it's just a Failure and would not always throw:
604+
throws-like { fails-not-throws }, Exception;
602605
603-
# test detects nothing got thrown, because our Failure wasn't sunk or made fatal:
604-
throws-like { no fatal; my $ = fails-not-throws; Nil }, Exception;
606+
# test detects nothing thrown, because our Failure wasn't sunk or made fatal:
607+
throws-like { no fatal; my $ = fails-not-throws; Nil }, Exception;
608+
=end code
605609
606-
Please note that you can only use the string form (for C<EVAL>) if you are not referencing
607-
any symbols in the surrounding scope. If you are, you should encapsulate
608-
your string with a block and an EVAL instead. For instance:
610+
Please note that you can only use the string form (for C<EVAL>) if you are not
611+
referencing any symbols in the surrounding scope. If you are, you should
612+
encapsulate your string with a block and an EVAL instead. For instance:
609613
610614
throws-like { EVAL q[ fac("foo") ] }, X::TypeCheck::Argument;
611615
612-
=head2 fails-like
616+
=head2 sub fails-like
613617
614618
Defined as:
615619
616-
sub fails-like ( \test where Callable:D|Str:D, $ex-type, $reason?, *%matcher)
620+
=for code
621+
sub fails-like ( \test where Callable:D|Str:D, $ex-type, $reason?, *%matcher)
617622
618623
Same interface as C<throws-like>, except checks that the code returns a
619-
L<Failure|/type/Failure> instead of throwing. If the code does throw or if the returned
620-
L<Failure|/type/Failure> has already been L<handled|/routine/handled>, that will be considered as a failed
621-
test.
624+
L<Failure|/type/Failure> instead of throwing. If the code does throw or if the
625+
returned L<Failure|/type/Failure> has already been L<handled|/routine/handled>,
626+
that will be considered as a failed test.
622627
623628
fails-like { +"a" }, X::Str::Numeric,
624629
:message(/'Cannot convert string to number'/),
625630
'converting non-numeric string to number fails';
626631
627-
=head2 subtest
632+
=head2 sub subtest
628633
629634
Defined as:
630635
@@ -656,8 +661,9 @@ subtest {
656661
}, "Check Great Uncle Bulgaria";
657662
=end code
658663
659-
You can also place the description as the first positional argument, or use a C<Pair> with description as the key and subtest's code
660-
as the value. This can be useful for subtests with large bodies.
664+
You can also place the description as the first positional argument, or use a
665+
C<Pair> with description as the key and subtest's code as the value. This can be
666+
useful for subtests with large bodies.
661667
662668
=begin code
663669
subtest 'A bunch of tests', {
@@ -673,8 +679,7 @@ subtest 'Another bunch of tests' => {
673679
}
674680
=end code
675681
676-
677-
=head2 todo
682+
=head2 sub todo
678683
679684
Defined as:
680685
@@ -709,7 +714,7 @@ Note that if you C<todo> a C<subtest>, all of the failing tests inside of it
709714
will be automatically marked TODO as well and will I<not> count towards your
710715
original TODO count.
711716
712-
=head2 skip
717+
=head2 sub skip
713718
714719
Defined as:
715720
@@ -735,7 +740,7 @@ else {
735740
Note that if you mark a test as skipped, you must also prevent that
736741
test from running.
737742
738-
=head2 skip-rest
743+
=head2 sub skip-rest
739744
740745
Defined as:
741746
@@ -767,7 +772,7 @@ to avoid running any tests at all and
767772
L«C<bail-out>|/language/testing#index-entry-bail-out-bail-out($reason?)» to abort
768773
the test run and mark it as failed.
769774
770-
=head2 bail-out
775+
=head2 sub bail-out
771776
772777
sub bail-out ($desc?)
773778
@@ -788,7 +793,7 @@ If you want to abort the test run, but without marking it as failed, see
788793
L«C<skip-rest>|/language/testing#index-entry-skip-rest-skip-rest($reason?)»
789794
or L«C<plan :skip-all('...')>|/language/testing#index-entry-plan-plan($count)»
790795
791-
=head2 pass
796+
=head2 sub pass
792797
793798
Defined as:
794799
@@ -805,13 +810,13 @@ Since these subroutines do not provide indication of what value was received
805810
and what was expected, they should be used sparingly, such as when evaluating
806811
a complex test condition.
807812
808-
=head2 flunk
813+
=head2 sub flunk
809814
810815
multi sub flunk($reason = '')
811816
812817
The opposite of C<pass>, makes a test fail with an optional message.
813818
814-
=head2 diag
819+
=head2 sub diag
815820
816821
sub diag($message)
817822

0 commit comments

Comments
 (0)