NAME
Test::Proto::Object - Test an object's behaviour
method
$p->method('open')->ok($subject); # i.e. method_exists
$p->method('open', ['test.txt','>'], [$fh])->ok($subject); # method_list_context
Either with one argument, takes the method, and checks if it exists, or takes three arguments, a method, the arguments to use with the method, and the expected return value. Calls the method on the test subject, with the arguments, and tests the return value.
The arguments and return value should be arrayrefs; the method is evaluated in list context.
method_void_context
$p->method('open', ['test.txt','>'])->ok($subject);
Takes two arguments, a method, and the arguments to use with the method. Calls the method on the test subject, with the arguments.
The arguments should be na arrayref; the method is evaluated in void context. This test will always pass, unless the method dies (or does not exist).
method_scalar_context
$p->method_scalar_context('open', ['test.txt','>'], $true)->ok($subject);
Takes three arguments, a method, the arguments to use with the method, and the expected return value. Calls the method on the test subject, with the arguments, and tests the return 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.
method_list_context
$p->method_list_context('open', ['test.txt','>'], [$true])->ok($subject);
Takes three arguments, a method, the arguments to use with the method, and the expected return value. Calls the method on the test subject, with the arguments, and tests the return value.
The arguments and return value should be arrayrefs; the method is evaluated in list context.
method_exists
$p->method_exists('open')->ok($subject);
Determines if the named method is present on the test subject. Implemented with can
, and does not pick up methods available via AUTOLOAD
.
OTHER INFORMATION
For author, version, bug reports, support, etc, please see Test::Proto.