Skip to content

Commit

Permalink
Merge pull request #452 from tbrowder/master
Browse files Browse the repository at this point in the history
add example of a user-entered tolerance; emphasize Test is a core module
  • Loading branch information
tbrowder committed Apr 22, 2016
2 parents b45c032 + f0bdcca commit 3c3dbc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion doc/Language/testing.pod
Expand Up @@ -26,7 +26,7 @@ project's base directory.
A typical test file looks something like this:
use v6;
use Test;
use Test; # a Standard module included with Rakudo
use lib 'lib';
plan $num-tests;
Expand Down Expand Up @@ -141,6 +141,16 @@ C<$description> of the test.
my $eulers-constant-approx = 2.71828;
is-approx $eulers-constant-approx, e, "approximate Euler's constant";
=item X<is-approx($value, $expected, $tol, $description?)|is-approx>
Marks a test as passed if the C<$value> and C<$expected> numerical values
are within C<$tol> of each other. The function accepts an optional
C<$description> of the test. For example, test for an approximation of pi:
my $pi-approx = 3.1416;
my $pi-tol = 0.0001;
is-approx $pi-approx, pi, $pi-tol, "approximate Pi";
=head2 By structural comparison
=item X<is-deeply($value, $expected, $description?)|is-deeply>
Expand Down
2 changes: 1 addition & 1 deletion doc/Language/traps.pod
Expand Up @@ -222,7 +222,7 @@ Here, C<tc> means "title case".
=head2 Strings are not iterable
There are methods that Str inherits from Any that work on iterables like lists. Interators on Strings contain one element that is the whole string. To use C<sort>, C<reverse> and friends, you need to split the string into a list first.
There are methods that Str inherits from Any that work on iterables like lists. Iterators on Strings contain one element that is the whole string. To use C<sort>, C<reverse> and friends, you need to split the string into a list first.
say "abc".reverse; # abc (what is wrong)
say "abc".comb.reverse.join; # cba
Expand Down

0 comments on commit 3c3dbc4

Please sign in to comment.