Test::Proto::Object - Test an object's behaviour
$p->method('open')->ok($subject); # i.e. method_exists $p->method('open', ['test.txt','>'], [$fh])->ok($subject); # method_list_context
With one argument, takes the method, and checks if it exists (using method_exists).
method_exists
With three arguments, takes takes 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 (it uses method_list_context).
method_list_context
$p->method_void_context('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).
$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.
$p->method_list_context('open', ['test.txt','>'], [$true])->ok($subject);
The arguments and return value should be arrayrefs; the method is evaluated in list context.
$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.
can
AUTOLOAD
For author, version, bug reports, support, etc, please see Test::Proto.
To install Test::Proto, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Proto
CPAN shell
perl -MCPAN -e shell install Test::Proto
For more information on module installation, please visit the detailed CPAN module installation guide.