Skip to content

Commit c2a94c5

Browse files
authored
Clarify is()'s usecases
1 parent 1dd3004 commit c2a94c5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

doc/Language/testing.pod6

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,17 @@ X<|is,testing>
215215
=item is($value, $expected, $description?)
216216
217217
Marks a test as passed if C<$value> and C<$expected> compare positively with
218-
the L<eq operator|/routine/eq>. The function accepts an optional
219-
C<$description> of the test.
218+
the L<eq operator|/routine/eq>, unless C<$expected> is a type object, in which
219+
case C<===> operator will be used instead; accepts an optional C<$description> of the test.
220+
221+
B<NOTE:> C<eq> operator the C<is()> uses stringifies,
222+
which means C<is()> is not a good function for testing more complex things, such
223+
as lists: C<is (1, (2, (3,))), [1, 2, 3]> passes the test, even though the operands
224+
are vastly different. For those cases, use
225+
L«C<is-deeply> routine|/language/testing#index-entry-is-deeply-is-deeply($value,_$expected,_$description?)»
220226
221227
is $pdf-document.author, "Joe", 'Retrieving the author field';
222228
is factorial(6), 720, 'Factorial - small integer';
223-
224-
As a special case, if C<$expected> is a type object, the comparison uses the
225-
C<===> operator instead:
226-
227229
my Int $a;
228230
is $a, Int, 'The variable $a is an unassigned Int';
229231

0 commit comments

Comments
 (0)