The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Test::Proto::CodeRef - Test a coderef's behaviour

METHODS

call

        $p->call(['test.txt','>'], [$fh])->ok($subject);

Takes two arguments: first, the arguments to pass to the code, second the expected return value. Passes the arguments to the test subject, and tests the return value against the expected value.

The arguments and return value should be arrayrefs; the code is evaluated in list context.

call_void_context

        $p->call_void_context(['test.txt','>'])->ok($subject);

Takes one argument: the arguments to use with the method, as an arrayref. Calls the method on the test subject, with the arguments. This test will always pass, unless the code dies, or is not code.

call_scalar_context

        $p->call_scalar_context(['test.txt','>'], $true)->ok($subject);

Takes two arguments: first, the arguments to pass to the code, second the expected return value. Passes the arguments to the test subject, and tests the return value against the expected value.

The arguments should be an arrayref, and the expected value should be a prototype evaluating the returned scalar, as the method is evaluated in scalar context.

call_list_context

        $p->call_list_context(['test.txt','>'], [$true])->ok($subject);

Takes two arguments: first, the arguments to pass to the code, second the expected return value. Passes the arguments to the test subject, and tests the return value against the expected value.

The arguments and return value should be arrayrefs; the code is evaluated in list context.

OTHER INFORMATION

For author, version, bug reports, support, etc, please see Test::Proto.