From: Stevan Little Date: Thu, 15 Mar 2007 21:43:39 +0000 (+0000) Subject: type fixes X-Git-Tag: 0_19~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c899258b097f8f334e0a0605bbcb321efeb48640;p=gitmo%2FMoose.git type fixes --- diff --git a/Changes b/Changes index c0c1a35..9c356a7 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ Revision history for Perl extension Moose +0.19 + * Moose::Util::TypeConstraints + - type now supports messages as well + (thanks to phaylon for finding this) + - added tests for this + 0.18 Sat. March 10, 2007 ~~ Many, many documentation updates ~~ diff --git a/README b/README index e62b526..b7bcdec 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Moose version 0.18 +Moose version 0.19 =========================== See the individual module documentation for more information diff --git a/lib/Moose.pm b/lib/Moose.pm index 8b7da28..e7c581e 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -4,7 +4,7 @@ package Moose; use strict; use warnings; -our $VERSION = '0.18'; +our $VERSION = '0.19'; our $AUTHORITY = 'cpan:STEVAN'; use Scalar::Util 'blessed', 'reftype'; diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index abd67f5..e77caf0 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -9,7 +9,7 @@ use Scalar::Util 'blessed'; use B 'svref_2object'; use Sub::Exporter; -our $VERSION = '0.11'; +our $VERSION = '0.12'; our $AUTHORITY = 'cpan:STEVAN'; use Moose::Meta::TypeConstraint; diff --git a/t/050_util_type_constraints.t b/t/050_util_type_constraints.t index bf8ef03..8e5b96a 100644 --- a/t/050_util_type_constraints.t +++ b/t/050_util_type_constraints.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 32; +use Test::More tests => 36; use Test::Exception; use Scalar::Util (); @@ -13,7 +13,9 @@ BEGIN { } type Number => where { Scalar::Util::looks_like_number($_) }; -type String => where { !ref($_) && !Number($_) }; +type String + => where { !ref($_) && !Number($_) } + => message { "This is not a string ($_)" }; subtype Natural => as Number @@ -85,4 +87,13 @@ is($natural->validate(-5), "Validation failed for 'Natural' failed", '... validated unsuccessfully (got error)'); +my $string = find_type_constraint('String'); +isa_ok($string, 'Moose::Meta::TypeConstraint'); +ok($string->has_message, '... it does have a message'); + +ok(!defined($string->validate("Five")), '... validated successfully (no error)'); + +is($string->validate(5), +"This is not a string (5)", +'... validated unsuccessfully (got error)');