Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:perl6/doc
  • Loading branch information
Paul Cochrane committed May 4, 2015
2 parents 086dcee + 679c478 commit fd8520f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
2 changes: 2 additions & 0 deletions lib/Language/concurrency.pod
Expand Up @@ -398,6 +398,8 @@ a simpler functional syntax to do this:
$channel.close;
await $p;
C<earliest> takes one or more channels and for the first one which has an item
available it will be passed to the C<more> block.
=head1 Low-level APIs
Expand Down
52 changes: 26 additions & 26 deletions lib/Language/testing.pod
Expand Up @@ -135,15 +135,15 @@ else {
}
=end code
=item skip_rest($reason?)
=item skip-rest($reason?)
Skip the remaining tests. If the remainder of the tests in the test file
would all fail due to some condition, use this function to skip them,
providing an optional C<$reason> as to why.
=begin code
unless $location ~~ "Wimbledon Common" {
skip_rest "We can't womble, the remaining tests will fail";
skip-rest "We can't womble, the remaining tests will fail";
exit;
}
Expand All @@ -152,8 +152,8 @@ ok(womble());
# ...
=end code
Note that C<skip_rest> requires a C<plan> to be set, otherwise the
C<skip_rest> call will throw an error. If no plan was set, you can use
Note that C<skip-rest> requires a C<plan> to be set, otherwise the
C<skip-rest> call will throw an error. If no plan was set, you can use
C<done> to indicate the end of the test run (though of course the test
summary will not count skipped tests).
Expand Down Expand Up @@ -199,14 +199,14 @@ optional C<$description> of the test.
$a = Nil;
isnt $a, Nil, 'Nil should not survive being put in a container';
=item cmp_ok($obtained, $comparison, $expected, $description?)
=item cmp-ok($obtained, $comparison, $expected, $description?)
The C<cmp_ok()> function compares the C<$obtained> and C<$expected> values
The C<cmp-ok()> function compares the C<$obtained> and C<$expected> values
with the given C<$comparison> operator and passes the test if the comparison
yields a C<True> value. For ease of use, operators may be passed as
strings, such as C<'=='> or C<'~~'>.
cmp_ok('my spelling is apperling', '~~', /perl/, "bad speller");
cmp-ok('my spelling is apperling', '~~', /perl/, "bad speller");
=head2 Matching output with a regular expression
Expand All @@ -226,7 +226,7 @@ defined directly in the argument to C<unlike>.
=head2 Structural comparison with C<< infix:<eqv> >>
=item is_deeply($obtained, $expected, $description?)
=item is-deeply($obtained, $expected, $description?)
Marks a test as passed if the C<$obtained> and C<$expected> values are
C<eqv>. This is the best way to check for equality of (deep) data
Expand All @@ -248,26 +248,26 @@ my %expected =
e => 3,
c => 1,
;
is_deeply count-chars('fleece'), %expected, 'count-chars works on "fleece"';
is-deeply count-chars('fleece'), %expected, 'count-chars works on "fleece"';
=end code
Note that string comparison here would have been fragile, because hashes are
not sorted, and converting a L<Hash|/type/Hash> to a string loses information.
=head2 Numeric comparison within a tolerance of 1e-5
=item is_approx($obtained, $expected, $description?)
=item is-approx($obtained, $expected, $description?)
Marks a test as passed if the C<$obtained> and C<$expected> numerical values
are within C<1e-5> of each other. The function accepts an optional
C<$description> of the test.
my $eulers_constant_approx = 2.71828;
is_approx($eulers_constant_approx, e, "approximate Euler's constant");
is-approx($eulers_constant_approx, e, "approximate Euler's constant");
=head2 Class membership testing
=item isa_ok($object, $type, $description?)
=item isa-ok($object, $type, $description?)
Marks a test as passed if the given C<$object> is, or inherits from, the
given C<$type>. For convenience, types may also be specified as a string.
Expand All @@ -277,8 +277,8 @@ The function accepts an optional C<$description> of the test.
class GreatUncleBulgaria is Womble {}
my $womble = GreatUncleBulgaria.new;
isa_ok($womble, Womble, "Great Uncle Bulgaria is a womble");
isa_ok($womble, 'Womble'); # equivalent
isa-ok($womble, Womble, "Great Uncle Bulgaria is a womble");
isa-ok($womble, 'Womble'); # equivalent
=head2 Grouping tests
Expand All @@ -301,15 +301,15 @@ class GreatUncleBulgaria is Womble {
subtest {
my $womble = GreatUncleBulgaria.new;
isa_ok($womble, Womble, "Great Uncle Bulgaria is a womble");
isa-ok($womble, Womble, "Great Uncle Bulgaria is a womble");
is($womble->location, "Wimbledon Common", "Correct location");
ok($womble->spectacles, "Wears spectacles");
}, "Check Great Uncle Bulgaria";
=end code
=head2 Exception testing
=item dies_ok($code, $description?)
=item dies-ok($code, $description?)
Marks the test as passed if the given C<$code> throws an exception.
Expand All @@ -320,10 +320,10 @@ sub saruman(Bool :$ents-destroy-isengard) {
die "Killed by Wormtongue" if $ents-destroy-isengard;
}
dies_ok { saruman(ents-destroy-isengard => True) }, "Saruman dies";
dies-ok { saruman(ents-destroy-isengard => True) }, "Saruman dies";
=end code
=item lives_ok($code, $description?)
=item lives-ok($code, $description?)
Marks the test as passed if the given C<$code> B<does not> throw an
exception.
Expand All @@ -335,38 +335,38 @@ sub frodo(Bool :$destroys-ring) {
die "Oops, that wasn't supposed to happen" unless $destroys-ring;
}
lives_ok { frodo(destroys-ring => True) }, "Frodo survivies";
lives-ok { frodo(destroys-ring => True) }, "Frodo survivies";
=end code
=item eval_dies_ok($code, $description?)
=item eval-dies-ok($code, $description?)
Marks the test as passed if the given C<eval>ed C<$code> throws an
exception.
The function accepts an optional C<$description> of the test.
=begin code
eval_dies_ok q[my $joffrey = "nasty";
eval-dies-ok q[my $joffrey = "nasty";
die "bye bye Ned" if $joffrey ~~ /nasty/],
"Ned Stark dies";
=end code
=item eval_lives_ok
=item eval-lives-ok
Marks the test as passed if the given C<eval>ed C<$code> throws an
exception.
The function accepts an optional C<$description> of the test.
=begin code
eval_lives_ok q[my $daenerys_burns = False;
eval-lives-ok q[my $daenerys_burns = False;
die "Oops, Khaleesi now ashes" if $daenerys_burns],
"Dany is blood of the dragon";
=end code
=item throws_like($code, $ex_type, $description?)
=item throws-like($code, $ex_type, $description?)
The C<throws_like> function checks whether the given C<$code> (specified as
The C<throws-like> function checks whether the given C<$code> (specified as
either something C<Callable>, or as a something to be C<EVAL>led) throws a
specific exception (either specified as a C<Type> object, or as a string).
If an exception was thrown, it will also try to match the matcher hash, in
Expand All @@ -379,7 +379,7 @@ Please note that you can only use the C<EVAL> form if you are not referencing
any symbols in the surrounding scope. If you are, you should encapsulate
your string with a block and an EVAL. For instance:
throws_like { EVAL q[ fac("foo") ] }, X::TypeCheck::Argument;
throws-like { EVAL q[ fac("foo") ] }, X::TypeCheck::Argument;
=end pod

Expand Down

0 comments on commit fd8520f

Please sign in to comment.