@@ -135,15 +135,15 @@ else {
135
135
}
136
136
= end code
137
137
138
- = item skip_rest ($reason?)
138
+ = item skip-rest ($reason?)
139
139
140
140
Skip the remaining tests. If the remainder of the tests in the test file
141
141
would all fail due to some condition, use this function to skip them,
142
142
providing an optional C < $reason > as to why.
143
143
144
144
= begin code
145
145
unless $location ~~ "Wimbledon Common" {
146
- skip_rest "We can't womble, the remaining tests will fail";
146
+ skip-rest "We can't womble, the remaining tests will fail";
147
147
exit;
148
148
}
149
149
@@ -152,8 +152,8 @@ ok(womble());
152
152
# ...
153
153
= end code
154
154
155
- Note that C < skip_rest > requires a C < plan > to be set, otherwise the
156
- C < skip_rest > call will throw an error. If no plan was set, you can use
155
+ Note that C < skip-rest > requires a C < plan > to be set, otherwise the
156
+ C < skip-rest > call will throw an error. If no plan was set, you can use
157
157
C < done > to indicate the end of the test run (though of course the test
158
158
summary will not count skipped tests).
159
159
@@ -199,14 +199,14 @@ optional C<$description> of the test.
199
199
$a = Nil;
200
200
isnt $a, Nil, 'Nil should not survive being put in a container';
201
201
202
- = item cmp_ok ($obtained, $comparison, $expected, $description?)
202
+ = item cmp-ok ($obtained, $comparison, $expected, $description?)
203
203
204
- The C < cmp_ok ()> function compares the C < $obtained > and C < $expected > values
204
+ The C < cmp-ok ()> function compares the C < $obtained > and C < $expected > values
205
205
with the given C < $comparison > operator and passes the test if the comparison
206
206
yields a C < True > value. For ease of use, operators may be passed as
207
207
strings, such as C < '==' > or C < '~~' > .
208
208
209
- cmp_ok ('my spelling is apperling', '~~', /perl/, "bad speller");
209
+ cmp-ok ('my spelling is apperling', '~~', /perl/, "bad speller");
210
210
211
211
= head2 Matching output with a regular expression
212
212
@@ -226,7 +226,7 @@ defined directly in the argument to C<unlike>.
226
226
227
227
= head2 Structural comparison with C << infix:<eqv> >>
228
228
229
- = item is_deeply ($obtained, $expected, $description?)
229
+ = item is-deeply ($obtained, $expected, $description?)
230
230
231
231
Marks a test as passed if the C < $obtained > and C < $expected > values are
232
232
C < eqv > . This is the best way to check for equality of (deep) data
@@ -248,26 +248,26 @@ my %expected =
248
248
e => 3,
249
249
c => 1,
250
250
;
251
- is_deeply count-chars('fleece'), %expected, 'count-chars works on "fleece"';
251
+ is-deeply count-chars('fleece'), %expected, 'count-chars works on "fleece"';
252
252
= end code
253
253
254
254
Note that string comparison here would have been fragile, because hashes are
255
255
not sorted, and converting a L < Hash|/type/Hash > to a string loses information.
256
256
257
257
= head2 Numeric comparison within a tolerance of 1e-5
258
258
259
- = item is_approx ($obtained, $expected, $description?)
259
+ = item is-approx ($obtained, $expected, $description?)
260
260
261
261
Marks a test as passed if the C < $obtained > and C < $expected > numerical values
262
262
are within C < 1e-5 > of each other. The function accepts an optional
263
263
C < $description > of the test.
264
264
265
265
my $eulers_constant_approx = 2.71828;
266
- is_approx ($eulers_constant_approx, e, "approximate Euler's constant");
266
+ is-approx ($eulers_constant_approx, e, "approximate Euler's constant");
267
267
268
268
= head2 Class membership testing
269
269
270
- = item isa_ok ($object, $type, $description?)
270
+ = item isa-ok ($object, $type, $description?)
271
271
272
272
Marks a test as passed if the given C < $object > is, or inherits from, the
273
273
given C < $type > . For convenience, types may also be specified as a string.
@@ -277,8 +277,8 @@ The function accepts an optional C<$description> of the test.
277
277
class GreatUncleBulgaria is Womble {}
278
278
279
279
my $womble = GreatUncleBulgaria.new;
280
- isa_ok ($womble, Womble, "Great Uncle Bulgaria is a womble");
281
- isa_ok ($womble, 'Womble'); # equivalent
280
+ isa-ok ($womble, Womble, "Great Uncle Bulgaria is a womble");
281
+ isa-ok ($womble, 'Womble'); # equivalent
282
282
283
283
= head2 Grouping tests
284
284
@@ -301,15 +301,15 @@ class GreatUncleBulgaria is Womble {
301
301
302
302
subtest {
303
303
my $womble = GreatUncleBulgaria.new;
304
- isa_ok ($womble, Womble, "Great Uncle Bulgaria is a womble");
304
+ isa-ok ($womble, Womble, "Great Uncle Bulgaria is a womble");
305
305
is($womble->location, "Wimbledon Common", "Correct location");
306
306
ok($womble->spectacles, "Wears spectacles");
307
307
}, "Check Great Uncle Bulgaria";
308
308
= end code
309
309
310
310
= head2 Exception testing
311
311
312
- = item dies_ok ($code, $description?)
312
+ = item dies-ok ($code, $description?)
313
313
314
314
Marks the test as passed if the given C < $code > throws an exception.
315
315
@@ -320,10 +320,10 @@ sub saruman(Bool :$ents-destroy-isengard) {
320
320
die "Killed by Wormtongue" if $ents-destroy-isengard;
321
321
}
322
322
323
- dies_ok { saruman(ents-destroy-isengard => True) }, "Saruman dies";
323
+ dies-ok { saruman(ents-destroy-isengard => True) }, "Saruman dies";
324
324
= end code
325
325
326
- = item lives_ok ($code, $description?)
326
+ = item lives-ok ($code, $description?)
327
327
328
328
Marks the test as passed if the given C < $code > B < does not > throw an
329
329
exception.
@@ -335,38 +335,38 @@ sub frodo(Bool :$destroys-ring) {
335
335
die "Oops, that wasn't supposed to happen" unless $destroys-ring;
336
336
}
337
337
338
- lives_ok { frodo(destroys-ring => True) }, "Frodo survivies";
338
+ lives-ok { frodo(destroys-ring => True) }, "Frodo survivies";
339
339
= end code
340
340
341
- = item eval_dies_ok ($code, $description?)
341
+ = item eval-dies-ok ($code, $description?)
342
342
343
343
Marks the test as passed if the given C < eval > ed C < $code > throws an
344
344
exception.
345
345
346
346
The function accepts an optional C < $description > of the test.
347
347
348
348
= begin code
349
- eval_dies_ok q[my $joffrey = "nasty";
349
+ eval-dies-ok q[my $joffrey = "nasty";
350
350
die "bye bye Ned" if $joffrey ~~ /nasty/],
351
351
"Ned Stark dies";
352
352
= end code
353
353
354
- = item eval_lives_ok
354
+ = item eval-lives-ok
355
355
356
356
Marks the test as passed if the given C < eval > ed C < $code > throws an
357
357
exception.
358
358
359
359
The function accepts an optional C < $description > of the test.
360
360
361
361
= begin code
362
- eval_lives_ok q[my $daenerys_burns = False;
362
+ eval-lives-ok q[my $daenerys_burns = False;
363
363
die "Oops, Khaleesi now ashes" if $daenerys_burns],
364
364
"Dany is blood of the dragon";
365
365
= end code
366
366
367
- = item throws_like ($code, $ex_type, $description?)
367
+ = item throws-like ($code, $ex_type, $description?)
368
368
369
- The C < throws_like > function checks whether the given C < $code > (specified as
369
+ The C < throws-like > function checks whether the given C < $code > (specified as
370
370
either something C < Callable > , or as a something to be C < EVAL > led) throws a
371
371
specific exception (either specified as a C < Type > object, or as a string).
372
372
If an exception was thrown, it will also try to match the matcher hash, in
@@ -379,7 +379,7 @@ Please note that you can only use the C<EVAL> form if you are not referencing
379
379
any symbols in the surrounding scope. If you are, you should encapsulate
380
380
your string with a block and an EVAL. For instance:
381
381
382
- throws_like { EVAL q[ fac("foo") ] }, X::TypeCheck::Argument;
382
+ throws-like { EVAL q[ fac("foo") ] }, X::TypeCheck::Argument;
383
383
384
384
= end pod
385
385
0 commit comments