gitpan / test-fatal-matchfor Goto Github PK
View Code? Open in Web Editor NEWRead-only release history for Test-Fatal-matchfor
Home Page: http://metacpan.org/release/Test-Fatal-matchfor
License: Other
Read-only release history for Test-Fatal-matchfor
Home Page: http://metacpan.org/release/Test-Fatal-matchfor
License: Other
NAME Test::Fatal::matchfor - match exceptions by class name or regexp SYNOPSIS Let's say you're testing the following Moose class... package Goose { use Moose; has feather_count => (is => 'rw', isa => 'Int'); } In Moose 2.1102 and above, exception objects are thrown, but in earlier versions of Moose, only string errors are given. So we might want to test it something like this: use Test::More; use Test::Fatal; use Goose; my $e = exception { Goose->new(feather_count => 3.1) }; ref($e) ? isa_ok($e, 'Moose::Exception::ValidationFailedForTypeConstraint') : like($e, qr{does not pass the type constraint}) This module provides a small shortcut for that pattern: use Test::More; use Test::Fatal; use Test::Fatal::matchfor; use Goose; my $e = exception { Goose->new(feather_count => 3.1) }; is( $e, matchfor( 'Moose::Exception::ValidationFailedForTypeConstraint', qr{does not pass the type constraint}, ), ); DESCRIPTION Test::Fatal::matchfor exports the `matchfor` function which accepts a list of class/role names and regular expressions, and constructs an object overloading `==` and `eq` to return true if compared for equality against a string that matches one of those regular expressions, or an object that isa/does one of those class/role names. So for example, to check a type constraint error in Moose, you might use: my $tc_err = matchfor( 'Moose::Exception::ValidationFailedForTypeConstraint', 'Moose::Exception::ValidationFailedForInlinedTypeConstraint', qr{does not pass the type constraint}, ), is($exception, $tc_err, "encountered error as expected"); BUGS Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Test-Fatal-matchfor>. SEE ALSO Test::Fatal, Moose::Exception. AUTHOR Toby Inkster <[email protected]>. COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. DISCLAIMER OF WARRANTIES THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.