sub cmp-ok

Documentation for sub cmp-ok assembled from the following types:

class Test

From Test

(Test) sub cmp-ok

multi sub cmp-ok(Mu $got is raw$opMu $expected is raw$desc = '')

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 { $^a / $^b  < rand };
    cmp-ok 1&my-comp2'the dice giveth and the dice taketh away'
    cmp-ok 2-> $a$b { $ and $ and $a < $b }7,
        'we got primes, one larger than the other!';