Test::Interface - Test if a class implements an interface
To create an Interface:
package MyProject::Foo::Interface; use Role::MethodReturns; around my_foo_method => class_method ( Str, $foo, Int $bar ) { returns_object_does_interface( 'MyProject::Bar::Interface'( $original->( $class => ( $foo, $bar ) ) }
And in some implementation:
package MyProject::Foo sub my_foo_method { ... } ...
And in tests:
use Test::Most; use Test::Interface; interface_ok('MyProject::Foo', 'MyProject::Foo::Interface', "huray! We implemented all methods!!" done_testing();
Test if a class implements an interface, using Role::Inspector
A bad attempt for writing readable interfaces.
Introspection for roles, providing does_role.
does_role
A minimalist role composition tool.
Which works fine for objects, but not for classes.
Theo van Hoesel <tvanhoesel@perceptyx.com>
'Test::Interface' is Copyright (C) 2020, Perceptyx Inc
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This library is distributed in the hope that it will be useful, but it is provided "as is" and without any express or implied warranties.
For details, see the full text of the license in the file LICENSE.
To install Test::Interface, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Interface
CPAN shell
perl -MCPAN -e shell install Test::Interface
For more information on module installation, please visit the detailed CPAN module installation guide.