NAME

Test::Role::TinyCommons::Tree - Test suite for Role::TinyCommons::Tree

VERSION

This document describes version 0.129 of Test::Role::TinyCommons::Tree (from Perl distribution RoleBundle-TinyCommons-Tree), released on 2021-10-07.

DESCRIPTION

This module provides a test suite for roles in Role::TinyCommons::Tree distribution.

FUNCTIONS

test_role_tinycommons_tree(%args)

Test a class against roles in Role::TinyCommons::Tree distribution.

To run the tests, you need to provide a class name to test in class. You have to load the class yourself. The class must at least consume the role Role::TinyCommons::Tree::Node (and other roles too, if you want to test the other roles). You also need to provide two subclasses names in subclass1 and subclass2. They must be subclass of the main class, and one must not be subclasses of the other. You are also responsible to load these two subclasses.

Options:

  • class* => str

    The main class to test.

  • subclass1* => str

  • subclass2* => str

  • attribute1 => str (default: id)

    An attribute (rw, int) is needed for testing. The default is id, but you can set a custom attribute.

  • code_instantiate => code

    Required if your constructor does not accept name-value pairs ($class->new(id => ...)). Code will be supplied ($class, \%attrs) and must return an object.

  • constructor_name => str (default: new)

    Must be set if your constructor name is not the default new.

  • test_fromstruct => bool (default: 0)

    Whether to test class against Role::TinyCommons::Tree::FromStruct. If you enable this, your class must consume the role.

    If that attribute needs to be set during construction, and your constructor does not accept name-value pairs ($class->new(id => ...)), then you'll need to supply code_instantiate which will be passed <($class, \%attrs)> so you can instantiate your object yourself.

  • test_nodemethods => bool (default: 0)

    Whether to test class against Role::TinyCommons::Tree::NodeMethods. If you enable this, your class must consume the role.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/RoleBundle-TinyCommons-Tree.

SOURCE

Source repository is at https://github.com/perlancar/perl-RoleBundle-TinyCommons-Tree.

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 2020, 2016 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=RoleBundle-TinyCommons-Tree

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.