Documentation for sub cmp-ok
assembled from the following pages:
Module: Test §
From Test
(Test) sub cmp-ok §
multi sub cmp-ok(Mu is raw, , Mu is raw, = '')
Compares $got
and $expected
with the given $op
comparator and passes the test if the comparison yields a True
value. The description of the test is optional.
The $op
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 $op
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!';