sub cmp-ok
Documentation for sub cmp-ok
assembled from the following types:
module Test
From Test
(Test) sub cmp-ok
multi sub cmp-ok(Mu is raw, , Mu is raw, = '')
Compares $value
and $expected
with the given $comparison
comparator and passes the test if the comparison yields a True
value. The description of the test is optional.
The $comparison
comparator can be either a Callable or a Str containing an infix operator, such as '=='
, a '~~'
, or a user-defined infix.
cmp-ok 'my spelling is apperling', '~~', /perl/, "bad speller";
Metaoperators cannot be given as a string; pass them as a Callable instead:
cmp-ok <a b c>, &[!eqv], <b d e>, 'not equal';
A Callable $comparison
lets you use custom comparisons:
sub my-comp ;cmp-ok 1, , 2, 'the dice giveth and the dice taketh away'cmp-ok 2, -> , , 7,'we got primes, one larger than the other!';