Skip to content

Commit b2b04fa

Browse files
committed
Document new features of is()/isnt()
1 parent d45aed3 commit b2b04fa

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/Language/testing.pod

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,30 @@ a test as passed if the given condition evaluates to C<False>.
171171
172172
=item is($obtained, $expected, $description?)
173173
174-
Marks a test as passed if the C<$obtained> and C<$expected> values are equal
175-
when coerced to strings (i.e., they compare as equal when using the
176-
L<eq operator|/routine/eq>). The function
174+
Marks a test as passed if the C<$obtained> and C<$expected> values are equal.
175+
If C<$expected> is a type object, then the comparison operator is C<===>.
176+
If C<$expected> is defined, then C<$obtained> and C<$expected> are coerced
177+
to strings and compared using the L<eq operator|/routine/eq>). The function
177178
accepts an optional C<$description> of the test.
178179
179180
my $pi = 3;
180181
is($pi, 3, 'The variable $pi equals 3');
181182
183+
my Int $a;
184+
is $a, Int, 'The variable $a is an unassigned Int';
185+
182186
=item isnt($obtained, $expected, $description?)
183187
184188
Marks a test as passed if the C<$obtained> and C<$expected> values are
185-
B<not> equal (i.e., they compare as B<not> equal when using the C<'eq'>
186-
operator). The function accepts an optional C<$description> of the test.
189+
B<not> equal using the same rules as C<is()>. The function accepts an
190+
optional C<$description> of the test.
187191
188192
isnt(pi, 3, 'The constant π is not equal to 3');
189193
194+
my Int $a = 23;
195+
$a = Nil;
196+
isnt $a, Nil, 'Nil should not survive being put in a container';
197+
190198
=item cmp_ok($obtained, $comparison, $expected, $description?)
191199
192200
The C<cmp_ok()> function compares the C<$obtained> and C<$expected> values

0 commit comments

Comments
 (0)