NAME

Fennec::Plugin - Used by plugins to turn them into plugins.

DESCRIPTION

All plugins must use this class to define their exported functionality.

EARLY VERSION WARNING

This is VERY early version. Fennec does not run yet.

Please go to http://github.com/exodist/Fennec to see the latest and greatest.

SYNOPSYS

To create a plugin create a module directly under the Fennec::Plugin namespace. Define testers and utilies.

package Fennec::Plugin::MyPlugin;
use strict;
use references;
use Fennec::Plugin;

# define a util function
util my_diag => sub { Fennec->diag( @_ ) };

# define a tester
tester my_ok => (
    min_args => 1,
    max_args => 2,
    code => sub {
        my ( $result, $name ) = @_;
        return ( $result ? 1 : 0, $name );
    },
);

# Define one with a prototype
tester my_dies_ok => sub(&;$) {
    eval $_[0]->() || return ( 1, $_[1]);
    Fennec->diag( "Test did not die as expected" );
    return ( 0, $_[1] );
};

1;

WRAPPER PLUGINS

Plugins can be made to wrap around existing Test::Builder based testing utilities. This is how Test::More and Test::Warn functionality is provided. Here is the Test::More wrapper plugin as an example.

package Fennec::Plugin::More;
use strict;
use warnings;

use Fennec::Plugin;

our @SUBS;
BEGIN {
    @SUBS = qw/ is isnt like unlike cmp_ok is_deeply can_ok isa_ok /;
}

use Test::More import => \@SUBS;

tester $_ => $_ for @SUBS;
util diag => sub { Fennec->diag( @_ ) };
util todo => sub(&$) {
    my ( $code, $todo ) = @_;
    local $Fennec::Plugin::TODO = $todo;
    $code->();
};

1;

TESTING

TODO

ADVANCED TESTERS

TODO - talk about defining argument types

IMPORT

CLASS METHODS

my $reason = $class->todo()

If the tests are currently runnign under TODO this will returnt he reason, otherwise it will return false.

$class->export_to( $package )

Export testers and utils from the plugin to the specified package.

EXPORTED FUNCTIONS

These functions are exported for use in your plugins.

no_test()

If a tester sub returns the result of this function then no test will be recorded. This can be used to abord a tester without any record.

util( $name, $code )
util( $name, %proto )

Define a utility function.

tester( $name, $code )
tester( $name, %proto )

Define a tester function.

AUTHORS

Chad Granum exodist7@gmail.com

COPYRIGHT

Copyright (C) 2010 Chad Granum

Fennec is free software; Standard perl licence.

Fennec is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.