@@ -152,8 +152,8 @@ summary will not count skipped tests).
152
152
= item ok($condition, $description?), nok($condition, $description?)
153
153
154
154
The C < ok > function marks a test as passed if the given C < $condition >
155
- evaluates to C < True > . The C < nok > function marks a test as passed if the
156
- given condition evaluates to C < False > .
155
+ evaluates to C < True > in a boolean context. The C < nok > function marks
156
+ a test as passed if the given condition evaluates to C < False > .
157
157
158
158
plan 2;
159
159
@@ -166,7 +166,8 @@ given condition evaluates to C<False>.
166
166
= item is($obtained, $expected, $description?)
167
167
168
168
Marks a test as passed if the C < $obtained > and C < $expected > values are equal
169
- (i.e., they compare as equal when using the C < 'eq' > operator). The function
169
+ when coerced to strings (i.e., they compare as equal when using the
170
+ L < eq operator|/routine/eq > ). The function
170
171
accepts an optional C < $description > of the test.
171
172
172
173
my $pi = 3;
@@ -197,7 +198,27 @@ Marks a test as passed if the C<$obtained> and C<$expected> values are
197
198
C < eqv > . This is the best way to check for equality of (deep) data
198
199
structures. The function accepts an optional C < $description > of the test.
199
200
200
- TODO: add an example
201
+ = begin code
202
+ use v6;
203
+ use Test;
204
+ plan 1;
205
+
206
+ sub count-chars(Str() $x) {
207
+ my %chars;
208
+ %chars{$_}++ for $x.comb;
209
+ return %chars;
210
+ }
211
+ my %expected =
212
+ f => 1,
213
+ l => 1,
214
+ e => 3,
215
+ c => 1,
216
+ ;
217
+ is_deeply count-chars('fleece'), %expected, 'count-chars works on "fleece"';
218
+ = end code
219
+
220
+ Note that string comparison here would have been fragile, because hashes are
221
+ not sorted, and converting a L < Hash|/type/Hash > to a string loses information.
201
222
202
223
= head2 Numeric comparison within a tolerance of 1e-5
203
224
0 commit comments