NAME
Test::Proto::Object - Test Prototype for objects.
SYNOPSIS
Test::Proto::Object->new->ok($object); # ok
Test::Proto::Object->new->ok('1'); # not ok
Test::Proto::Object
->new->try_can(
'toString', [], ['<div/>'], 'Element div toString returns <div/>'
)->ok($object);
This is a test prototype which requires that the value it is given is defined and is a scalar. It provides methods for interacting with strings.
METHODS
See Test::Proto::Base for documentation on common methods.
can
$prototype->can('toString', 'has a toString method')->ok($object);
This method adds a test equivalent to Perl's builtin can
, i.e. tests if an object has a method with the given name. It does not actually execute this method.
try_can
$prototype->try_can('toString', [], ['<div/>'], 'Element div toString returns <div/>')->ok($object);
# is_deeply($object->toString (), ['<div/>'], 'Element div toString returns <div/>');
This method allows you to make method calls to your object and test the result. Arguments are: 1) the method name; 2) an arrayref containing the arguments you want to pass to the method call; 3) an arrayref containing the results; 4) Optionally, the reason for the test.
NB: Results are evaluated in list context and what is available for testing is always an arrayref.
OTHER INFORMATION
For author, version, bug reports, support, etc, please see Test::Proto.