Guillaume Aubert > Test-Type-v1.2.0 > Test::Type

Download:
Test-Type-v1.2.0.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: v1.2.0   Source  

NAME ^

Test::Type - Functions to validate data types in test files.

VERSION ^

Version 1.2.0

SYNOPSIS ^

        use Test::Type;

        # Test strings.
        ok_string( $variable );
        ok_string(
                $variable,
                name => 'My variable',
        );

        # Test arrayrefs.
        ok_arrayref( $variable );
        ok_arrayref(
                $variable,
                name => 'My variable',
        );

        # Test hashrefs.
        ok_hashref( $variable );
        ok_hashref(
                $variable,
                name => 'Test variable',
        );

        # Test coderefs.
        ok_coderef( $variable );
        ok_coderef(
                $variable,
                name => 'Test variable',
        );

        # Test numbers.
        ok_number( $variable );
        ok_number(
                $variable,
                name => 'Test variable',
        );

        # Test instances.
        ok_instance(
                $variable,
                class => $class,
        );
        ok_instance(
                $variable,
                name  => 'Test variable',
                class => $class,
        );

        # Test regular expressions.
        ok_regex( $variable );
        ok_regex(
                $variable,
                name => 'Test regular expression',
        );

FUNCTIONS ^

ok_string()

Test if the variable passed is a string.

        ok_string(
                $variable,
        );

        ok_string(
                $variable,
                name => 'My variable',
        );

        ok_string(
                $variable,
                name        => 'My variable',
                allow_empty => 1,
        );

Parameters:

ok_arrayref()

Test if the variable passed is an arrayref that can be dereferenced into an array.

        ok_arrayref( $variable );

        ok_arrayref(
                $variable,
                name => 'My variable',
        );

        ok_arrayref(
                $variable,
                allow_empty => 1,
                no_blessing => 0,
        );

        # Check if the variable is an arrayref of hashrefs.
        ok_arrayref(
                $variable,
                allow_empty           => 1,
                no_blessing           => 0,
                element_validate_type =>
                        sub
                        {
                                return Data::Validate::Type::is_hashref( $_[0] );
                        },
        );

Parameters:

ok_hashref()

Test if the variable passed is a hashref that can be dereferenced into a hash.

        ok_hashref( $variable );

        ok_hashref(
                $variable,
                name => 'Test variable',
        );

        ok_hashref(
                $variable,
                allow_empty => 1,
                no_blessing => 0,
        );

Parameters:

ok_coderef()

Test if the variable passed is an coderef that can be dereferenced into a block of code.

        ok_coderef( $variable );

        ok_coderef(
                $variable,
                name => 'Test variable',
        );

Parameters:

ok_number()

Test if the variable passed is a number.

        ok_number( $variable );

        ok_number(
                $variable,
                name => 'Test variable',
        );

        ok_number(
                $variable,
                positive => 1,
        );

        ok_number(
                $variable,
                strictly_positive => 1,
        );

Parameters:

ok_instance()

Test if the variable is an instance of the given class.

Note that this handles inheritance properly, so it will succeed if the variable is an instance of a subclass of the class given.

        ok_instance(
                $variable,
                class => $class,
        );

        ok_instance(
                $variable,
                name  => 'Test variable',
                class => $class,
        );

Parameters:

ok_regex()

Test if the variable is a regular expression.

        ok_regex( $variable );

BUGS ^

Please report any bugs or feature requests to bug-test-dist-versionsync at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=test-type. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

        perldoc Test::Type

You can also look for information at:

AUTHOR ^

Guillaume Aubert, <aubertg at cpan.org>.

COPYRIGHT & LICENSE ^

Copyright 2012-2014 Guillaume Aubert.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.

This program 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 GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/

syntax highlighting: