Skip to content

Commit cfb6e81

Browse files
committed
Eliminates non-existing variable
Also some reflow, some additional comments, overall closes #2466
1 parent 2c1c964 commit cfb6e81

File tree

1 file changed

+35
-29
lines changed

1 file changed

+35
-29
lines changed

doc/Type/Test.pod6

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ Defined as:
107107
108108
The C<ok> function marks a test as passed if the given C<$value> evaluates to
109109
C<True>. The C<nok> function marks a test as passed if the given value evaluates
110-
to C<False>. Both functions accept an optional C<$description> of the test.
110+
to C<False>. Both functions accept an optional description of the test as second
111+
parameter.
111112
112113
my $response; my $query; ...;
113114
ok $response.success, 'HTTP response was successful';
@@ -130,7 +131,8 @@ Defined as:
130131
multi sub nok(Mu $cond, $desc = '')
131132
132133
The C<nok> function marks a test as passed if the given value evaluates to
133-
C<False>. It also accepts an optional C<$description> of the test.
134+
C<False>. It also accepts an optional description of the test as second
135+
argument.
134136
135137
my $response; my $query; ...;
136138
ok $response.success, 'HTTP response was successful';
@@ -146,13 +148,13 @@ Defined as
146148
147149
Marks a test as passed if C<$value> and C<$expected> compare positively with the
148150
L<eq operator|/routine/eq>, unless C<$expected> is a type object, in which case
149-
C<===> operator will be used instead; accepts an optional C<$description> of the
150-
test.
151+
C<===> operator will be used instead; accepts an optional description of the
152+
test as the last argument.
151153
152-
B<NOTE:> C<eq> operator the C<is()> uses stringifies,
153-
which means C<is()> is not a good function for testing more complex things, such
154-
as lists: C<is (1, (2, (3,))), [1, 2, 3]> passes the test, even though the operands
155-
are vastly different. For those cases, use
154+
B<NOTE:> C<eq> operator the C<is()> uses stringifies, which means C<is()> is not
155+
a good function for testing more complex things, such as lists: C<is (1, (2,
156+
(3,))), [1, 2, 3]> passes the test, even though the operands are vastly
157+
different. For those cases, use
156158
L«C<is-deeply> routine|/language/testing#index-entry-is-deeply-is-deeply($value,_$expected,_$description?)»
157159
158160
my $pdf-document; sub factorial($x) { ... }; ...;
@@ -176,7 +178,7 @@ Defined as:
176178
multi sub isnt(Mu $got, Mu:D $expected, $desc = '')
177179
178180
Marks a test as passed if C<$value> and C<$expected> are B<not> equal using
179-
the same rules as C<is()>. The function accepts an optional C<$description>
181+
the same rules as C<is()>. The function accepts an optional description
180182
of the test.
181183
182184
isnt pi, 3, 'The constant π is not equal to 3';
@@ -293,7 +295,7 @@ Defined as:
293295
Marks a test as passed if C<$value> and C<$expected> are equivalent, using the
294296
same semantics as the L<eqv operator|/routine/eqv>. This is the best way to
295297
check for equality of (deep) data structures. The function accepts an optional
296-
C<$description> of the test.
298+
description of the test as the last argument.
297299
298300
=begin code
299301
use Test;
@@ -327,7 +329,7 @@ L«C<cmp-ok $got, 'eqv', $expected, $desc>|/language/testing#By_arbitrary_compar
327329
multi sub cmp-ok(Mu $got is raw, $op, Mu $expected is raw, $desc = '')
328330
329331
Compares C<$value> and C<$expected> with the given C<$comparison> comparator and
330-
passes the test if the comparison yields a C<True> value. The C<$description>
332+
passes the test if the comparison yields a C<True> value. The description
331333
of the test is optional.
332334
333335
The C<$comparison> comparator can be either a L<Callable> or
@@ -357,7 +359,8 @@ Defined as:
357359
358360
Marks a test as passed if the given object C<$value> is, or inherits from, the
359361
given C<$expected-type>. For convenience, types may also be specified as a
360-
string. The function accepts an optional C<$description> of the test.
362+
string. The function accepts an optional description of the test, which
363+
defaults to a string that describes the object.
361364
362365
class Womble {}
363366
class GreatUncleBulgaria is Womble {}
@@ -373,7 +376,7 @@ Defined as:
373376
multi sub can-ok(Mu $var, Str $meth,$desc = "..." )
374377
375378
Marks a test as passed if the given C<$variable> can run the given
376-
C<$method-name>. The function accepts an optional C<$description>. For
379+
C<$method-name>. The function accepts an optional description. For
377380
instance:
378381
379382
class Womble {};
@@ -394,7 +397,7 @@ Defined as:
394397
multi sub does-ok(Mu $var, Mu $type, $desc = "...")
395398
396399
Marks a test as passed if the given C<$variable> can do the given C<$role>.
397-
The function accepts an optional C<$description> of the test.
400+
The function accepts an optional description of the test.
398401
399402
# create a Womble who can invent
400403
role Invent {
@@ -427,8 +430,8 @@ Use it this way:
427430
like 'foo', /fo/, 'foo looks like fo';
428431
429432
Marks a test as passed if the C<$value>, when coerced to a string, matches the
430-
C<$expected-regex>. The function accepts an optional C<$description> of the
431-
test.
433+
C<$expected-regex>. The function accepts an optional description of the
434+
test with a default value printing the expected match.
432435
433436
=head2 sub unlike
434437
@@ -441,8 +444,8 @@ Used this way:
441444
unlike 'foo', /bar/, 'foo does not look like bar';
442445
443446
Marks a test as passed if the C<$value>, when coerced to a string, does B<not>
444-
match the C<$expected-regex>. The function accepts an optional C<$description>
445-
of the test.
447+
match the C<$expected-regex>. The function accepts an optional description
448+
of the test, which defaults to printing the text that did not match.
446449
447450
=head2 sub use-ok
448451
@@ -462,7 +465,7 @@ Defined as:
462465
463466
Marks a test as passed if the given C<$code> throws an exception.
464467
465-
The function accepts an optional C<$description> of the test.
468+
The function accepts an optional description of the test.
466469
467470
=begin code
468471
sub saruman(Bool :$ents-destroy-isengard) {
@@ -481,7 +484,7 @@ Defined as:
481484
Marks a test as passed if the given C<$code> B<does not> throw an
482485
exception.
483486
484-
The function accepts an optional C<$description> of the test.
487+
The function accepts an optional description of the test.
485488
486489
=begin code
487490
sub frodo(Bool :$destroys-ring) {
@@ -500,7 +503,7 @@ Defined as:
500503
Marks a test as passed if the given C<$string> throws an exception when
501504
C<eval>ed as code.
502505
503-
The function accepts an optional C<$description> of the test.
506+
The function accepts an optional description of the test.
504507
505508
=begin code
506509
eval-dies-ok q[my $joffrey = "nasty";
@@ -517,7 +520,7 @@ Defined as:
517520
Marks a test as passed if the given C<$string> B<does not> throw an
518521
exception when C<eval>ed as code.
519522
520-
The function accepts an optional C<$description> of the test.
523+
The function accepts an optional description of the test.
521524
522525
=begin code
523526
eval-lives-ok q[my $daenerys-burns = False;
@@ -532,20 +535,23 @@ Defined as:
532535
sub throws-like($code, $ex_type, $reason?, *%matcher)
533536
534537
Marks a test as passed if the given C<$code> throws the specific exception
535-
C<$expected-exception>. The code C<$code> may be specified as something
536-
C<Callable> or as a string to be C<EVAL>ed. The exception may be specified
537-
as a type object or as a string containing its type name.
538+
expected exception type C<$ex_type>. The code C<$code> may be specified as
539+
something C<Callable> or as a string to be C<EVAL>ed. The exception may be
540+
specified as a type object or as a string containing its type name.
538541
539542
If an exception was thrown, it will also try to match the matcher hash,
540543
where the key is the name of the method to be called on the exception, and
541544
the value is the value it should have to pass. For example:
542545
543546
=begin code
544-
sub frodo(Bool :$destroys-ring) { fail "Oops. Frodo dies" unless $destroys-ring };
547+
sub frodo(Bool :$destroys-ring) {
548+
fail "Oops. Frodo dies" unless $destroys-ring
549+
};
545550
throws-like { frodo }, Exception, message => /dies/;
546551
=end code
547552
548-
The function accepts an optional C<$description> of the test.
553+
The function accepts an optional description of the test as the third
554+
positional argument.
549555
550556
The routine makes L<Failures|/type/Failure> fatal. If you wish to avoid that,
551557
use L«C<no fatal> pragma|/language/pragmas#index-entry-fatal-fatal» and ensure
@@ -593,7 +599,7 @@ The C<subtest> function executes the given block, consisting of usually more
593599
than one test, possibly including a C<plan> or C<done-testing>, and counts as
594600
I<one> test in C<plan>, C<todo>, or C<skip> counts. It will pass the
595601
test only if B<all> tests in the block pass. The function accepts an
596-
optional C<$description> of the test.
602+
optional description of the subtest.
597603
598604
=begin code
599605
class Womble {}
@@ -752,7 +758,7 @@ Defined as:
752758
multi sub pass($desc = '')
753759
754760
The C<pass> function marks a test as passed. C<flunk> marks a test as
755-
B<not> passed. Both functions accept an optional test C<$description>.
761+
B<not> passed. Both functions accept an optional test description.
756762
757763
pass "Actually, this test has passed";
758764

0 commit comments

Comments
 (0)