NAME

Test::Proto - OO test script golf sugar

VERSION

Version 0.01

SYNOPSIS

This module simplifies writing tests for deep structures and objects.

    use Test::Proto;
	
    pAr	->contains_only('', pHr, 
			"ArrayRef must contain only an empty string followed by a hashref")
		->ok(["", {a=>'b'}]);

	pSt	->is_like(qr/^\d+$/, 'looks like a positive integer')
		->is_unlike(qr/^0\d+$/, 'no leading zeros')
		->ok('123');
	
	pOb	->is_a('XML::LibXML::Node', 'must inherit from XML::LibXML::Node')
		->is_a('XML::LibXML::Element', 'what it really is')
		->can_do('findnodes', 'must have the findnodes method')
		->try_can('localName', [], 'li')
		->ok(XML::LibXML::Element->new('li'));

The idea behind Test Proto is that test scripts for code written on modern, OO principles should themselves resemble the target code rather than sequential code.

Tests for deep structures and objects tend should not be repetitive and should be flexible so that when you decide you need $got->{'wurple'}{'diddle'}{'do'} to look like $got->{'wurple'}->diddle->[$i]{'do'} you can make a much smaller change to your script. Test::Proto is a framework primarily for testing the same thing for multiple conditions, and testing the things it contains/produces in a similar manner.

The way it works is that you create a "prototype" (using a subclass of Test::Proto::Base), add tests to the prototype, and validate then your string/arryref/object/etc. against the prototype.

FUNCTIONS

p

Returns a basic prototype. See Test::Proto::Base.

pSomething

Returns a defined prototype. See Test::Proto::Base.

pSt

Returns a string prototype. See Test::Proto::String.

pOb

Returns an object prototype. See Test::Proto::Object.

pAr

Returns an arrayref prototype. See Test::Proto::ArrayRef.

pHr

Returns a hashref prototype. See Test::Proto::HashRef.

pCr

Returns a coderef prototype. See Test::Proto::CodeRef.

pSeries

Returns a series. See Test::Proto::Series.

c

Returns a comparison object. See Test::Proto::Compare.

cNum

Returns a numeric comparison object. See Test::Proto::Compare::Numeric.

AUTHOR

Daniel Perrett, <perrettdl at googlemail.com>

BUGS

Please report any bugs or feature requests to bug-test-proto at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Proto. 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::Proto

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2012 Daniel Perrett.

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

See http://dev.perl.org/licenses/ for more information.