@@ -107,7 +107,8 @@ Defined as:
107
107
108
108
The C < ok > function marks a test as passed if the given C < $value > evaluates to
109
109
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.
111
112
112
113
my $response; my $query; ...;
113
114
ok $response.success, 'HTTP response was successful';
@@ -130,7 +131,8 @@ Defined as:
130
131
multi sub nok(Mu $cond, $desc = '')
131
132
132
133
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.
134
136
135
137
my $response; my $query; ...;
136
138
ok $response.success, 'HTTP response was successful';
@@ -146,13 +148,13 @@ Defined as
146
148
147
149
Marks a test as passed if C < $value > and C < $expected > compare positively with the
148
150
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 .
151
153
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
156
158
L « C < is-deeply > routine|/language/testing#index-entry-is-deeply-is-deeply($value,_$expected,_$description?)»
157
159
158
160
my $pdf-document; sub factorial($x) { ... }; ...;
@@ -176,7 +178,7 @@ Defined as:
176
178
multi sub isnt(Mu $got, Mu:D $expected, $desc = '')
177
179
178
180
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
180
182
of the test.
181
183
182
184
isnt pi, 3, 'The constant π is not equal to 3';
@@ -293,7 +295,7 @@ Defined as:
293
295
Marks a test as passed if C < $value > and C < $expected > are equivalent, using the
294
296
same semantics as the L < eqv operator|/routine/eqv > . This is the best way to
295
297
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 .
297
299
298
300
= begin code
299
301
use Test;
@@ -327,7 +329,7 @@ L«C<cmp-ok $got, 'eqv', $expected, $desc>|/language/testing#By_arbitrary_compar
327
329
multi sub cmp-ok(Mu $got is raw, $op, Mu $expected is raw, $desc = '')
328
330
329
331
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
331
333
of the test is optional.
332
334
333
335
The C < $comparison > comparator can be either a L < Callable > or
@@ -357,7 +359,8 @@ Defined as:
357
359
358
360
Marks a test as passed if the given object C < $value > is, or inherits from, the
359
361
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.
361
364
362
365
class Womble {}
363
366
class GreatUncleBulgaria is Womble {}
@@ -373,7 +376,7 @@ Defined as:
373
376
multi sub can-ok(Mu $var, Str $meth,$desc = "..." )
374
377
375
378
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
377
380
instance:
378
381
379
382
class Womble {};
@@ -394,7 +397,7 @@ Defined as:
394
397
multi sub does-ok(Mu $var, Mu $type, $desc = "...")
395
398
396
399
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.
398
401
399
402
# create a Womble who can invent
400
403
role Invent {
@@ -427,8 +430,8 @@ Use it this way:
427
430
like 'foo', /fo/, 'foo looks like fo';
428
431
429
432
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 .
432
435
433
436
= head2 sub unlike
434
437
@@ -441,8 +444,8 @@ Used this way:
441
444
unlike 'foo', /bar/, 'foo does not look like bar';
442
445
443
446
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 .
446
449
447
450
= head2 sub use-ok
448
451
@@ -462,7 +465,7 @@ Defined as:
462
465
463
466
Marks a test as passed if the given C < $code > throws an exception.
464
467
465
- The function accepts an optional C < $ description> of the test.
468
+ The function accepts an optional description of the test.
466
469
467
470
= begin code
468
471
sub saruman(Bool :$ents-destroy-isengard) {
@@ -481,7 +484,7 @@ Defined as:
481
484
Marks a test as passed if the given C < $code > B < does not > throw an
482
485
exception.
483
486
484
- The function accepts an optional C < $ description> of the test.
487
+ The function accepts an optional description of the test.
485
488
486
489
= begin code
487
490
sub frodo(Bool :$destroys-ring) {
@@ -500,7 +503,7 @@ Defined as:
500
503
Marks a test as passed if the given C < $string > throws an exception when
501
504
C < eval > ed as code.
502
505
503
- The function accepts an optional C < $ description> of the test.
506
+ The function accepts an optional description of the test.
504
507
505
508
= begin code
506
509
eval-dies-ok q[my $joffrey = "nasty";
@@ -517,7 +520,7 @@ Defined as:
517
520
Marks a test as passed if the given C < $string > B < does not > throw an
518
521
exception when C < eval > ed as code.
519
522
520
- The function accepts an optional C < $ description> of the test.
523
+ The function accepts an optional description of the test.
521
524
522
525
= begin code
523
526
eval-lives-ok q[my $daenerys-burns = False;
@@ -532,20 +535,23 @@ Defined as:
532
535
sub throws-like($code, $ex_type, $reason?, *%matcher)
533
536
534
537
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.
538
541
539
542
If an exception was thrown, it will also try to match the matcher hash,
540
543
where the key is the name of the method to be called on the exception, and
541
544
the value is the value it should have to pass. For example:
542
545
543
546
= 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
+ };
545
550
throws-like { frodo }, Exception, message => /dies/;
546
551
= end code
547
552
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.
549
555
550
556
The routine makes L < Failures|/type/Failure > fatal. If you wish to avoid that,
551
557
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
593
599
than one test, possibly including a C < plan > or C < done-testing > , and counts as
594
600
I < one > test in C < plan > , C < todo > , or C < skip > counts. It will pass the
595
601
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 .
597
603
598
604
= begin code
599
605
class Womble {}
@@ -752,7 +758,7 @@ Defined as:
752
758
multi sub pass($desc = '')
753
759
754
760
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.
756
762
757
763
pass "Actually, this test has passed";
758
764
0 commit comments