Documentation for sub
is assembled from the following types:
multi sub is(Mu , Mu , = '')multi sub is(Mu , Mu , = '')
Marks a test as passed if
$expected compare positively with the eq operator, unless
$expected is a type object, in which case
=== operator will be used instead; accepts an optional description of the test as the last argument.
eq operator the
is() uses stringifies, which means
is() is not a good function for testing more complex things, such as lists:
is (1, (2, (3,))), [1, 2, 3] passes the test, even though the operands are vastly different. For those cases, use
my ; sub factorial() ; ...;is .author, "Joe", 'Retrieving the author field';is factorial(6), 720, 'Factorial - small integer';my Int ;is , Int, 'The variable $a is an unassigned Int';
Note: if only whitespace differs between the values,
is() will output failure message differently, to show the whitespace in each values. For example, in the output below, the second test shows the literal
\t in the
is "foo\tbar", "foo\tbaz"; # expected: 'foo baz'␤# got: 'foo bar'is "foo\tbar", "foo bar"; # expected: "foo bar"␤# got: "foo\tbar"