In Traits§
See primary documentation in context for The is trait
proto trait_mod:<is>(Mu $, |) {*}
is
applies to any kind of scalar object, and can take any number of named or positional arguments. It is the most commonly used trait, and takes the following forms, depending on the type of the first argument.
In module Test§
See primary documentation in context for sub is
multi is(Mu $got, Mu:U $expected, $desc = '') multi is(Mu $got, Mu:D $expected, $desc = '')
Marks a test as passed if $got
and $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.
NOTE: the eq
operator stringifies its operands, 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 is-deeply
routine
my $pdf-document; sub factorial($x) { ... }; ...; is $pdf-document.author, "Joe", 'Retrieving the author field'; is factorial(6), 720, 'Factorial - small integer'; my Int $a; is $a, 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 got:
line:
is "foo\tbar", "foo\tbaz"; # expected: 'foo baz'# got: 'foo bar' is "foo\tbar", "foo bar"; # expected: "foo bar"# got: "foo\tbar"