sub ok

Documentation for sub ok assembled from the following types:

module Test

From Test

(Test) sub ok

Defined as:

multi sub ok(Mu $cond$desc = '')

The ok function marks a test as passed if the given $value evaluates to True. The nok function marks a test as passed if the given value evaluates to False. Both functions accept an optional description of the test as second parameter.

    my $responsemy $query...;
    ok  $response.success'HTTP response was successful';
    nok $query.error,      'Query completed without error';

In principle, you could use ok for every kind of comparison test, by including the comparison in the expression passed to $value:

    sub factorial($x{ ... };
    ok factorial(6== 720'Factorial - small integer';

However, where possible it's better to use one of the specialized comparison test functions below, because they can print more helpful diagnostics output in case the comparison fails.