r47933 - in /trunk/libmoosex-params-validate-perl: ChangeLog META.yml Makefile.PL debian/changelog debian/control lib/MooseX/Params/Validate.pm t/005_coercion.t
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Mon Nov 30 02:44:23 UTC 2009
Author: jawnsy-guest
Date: Mon Nov 30 02:44:11 2009
New Revision: 47933
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=47933
Log:
* New upstream release
* Standards-Version 3.8.3 (no changes)
Modified:
trunk/libmoosex-params-validate-perl/ChangeLog
trunk/libmoosex-params-validate-perl/META.yml
trunk/libmoosex-params-validate-perl/Makefile.PL
trunk/libmoosex-params-validate-perl/debian/changelog
trunk/libmoosex-params-validate-perl/debian/control
trunk/libmoosex-params-validate-perl/lib/MooseX/Params/Validate.pm
trunk/libmoosex-params-validate-perl/t/005_coercion.t
Modified: trunk/libmoosex-params-validate-perl/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-params-validate-perl/ChangeLog?rev=47933&op=diff
==============================================================================
--- trunk/libmoosex-params-validate-perl/ChangeLog (original)
+++ trunk/libmoosex-params-validate-perl/ChangeLog Mon Nov 30 02:44:11 2009
@@ -1,4 +1,10 @@
Revision history for Perl extension MooseX-Params-Validate
+
+0.13 Sun., Nov. 29, 2009
+ - Fix so that validated_hash does not try to coerce optional
+ parameters which are not present. Patch by Ian Sillitoe.
+
+ - Same fix for pos_validated_list. (Dave Rolsky)
0.12 Tue. Jul. 7, 2009
- Using the subroutine name as a cache key for validation specs
Modified: trunk/libmoosex-params-validate-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-params-validate-perl/META.yml?rev=47933&op=diff
==============================================================================
--- trunk/libmoosex-params-validate-perl/META.yml (original)
+++ trunk/libmoosex-params-validate-perl/META.yml Mon Nov 30 02:44:11 2009
@@ -28,4 +28,5 @@
Sub::Exporter: 0
resources:
license: http://dev.perl.org/licenses/
-version: 0.12
+ repository: http://code2.0beta.co.uk/moose/svn/MooseX-Params-Validate
+version: 0.13
Modified: trunk/libmoosex-params-validate-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-params-validate-perl/Makefile.PL?rev=47933&op=diff
==============================================================================
--- trunk/libmoosex-params-validate-perl/Makefile.PL (original)
+++ trunk/libmoosex-params-validate-perl/Makefile.PL Mon Nov 30 02:44:11 2009
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use inc::Module::Install;
+use inc::Module::Install 0.91;
name 'MooseX-Params-Validate';
all_from 'lib/MooseX/Params/Validate.pm';
@@ -18,4 +18,6 @@
license 'Perl';
+resources repository => 'http://code2.0beta.co.uk/moose/svn/MooseX-Params-Validate';
+
WriteAll();
Modified: trunk/libmoosex-params-validate-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-params-validate-perl/debian/changelog?rev=47933&op=diff
==============================================================================
--- trunk/libmoosex-params-validate-perl/debian/changelog (original)
+++ trunk/libmoosex-params-validate-perl/debian/changelog Mon Nov 30 02:44:11 2009
@@ -1,4 +1,8 @@
-libmoosex-params-validate-perl (0.12-2) UNRELEASED; urgency=low
+libmoosex-params-validate-perl (0.13-1) UNRELEASED; urgency=low
+
+ [ Jonathan Yu ]
+ * New upstream release
+ * Standards-Version 3.8.3 (no changes)
[ Salvatore Bonaccorso ]
* debian/control: Changed: Replace versioned (build-)dependency on
@@ -8,7 +12,7 @@
[ Ryan Niebur ]
* Update jawnsy's email address
- -- Ryan Niebur <ryanryan52 at gmail.com> Tue, 01 Sep 2009 21:19:19 -0700
+ -- Jonathan Yu <jawnsy at cpan.org> Sun, 29 Nov 2009 18:22:03 -0500
libmoosex-params-validate-perl (0.12-1) unstable; urgency=low
Modified: trunk/libmoosex-params-validate-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-params-validate-perl/debian/control?rev=47933&op=diff
==============================================================================
--- trunk/libmoosex-params-validate-perl/debian/control (original)
+++ trunk/libmoosex-params-validate-perl/debian/control Mon Nov 30 02:44:11 2009
@@ -8,7 +8,7 @@
libdevel-caller-perl, perl
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
Uploaders: Jonathan Yu <jawnsy at cpan.org>
-Standards-Version: 3.8.2
+Standards-Version: 3.8.3
Homepage: http://search.cpan.org/dist/MooseX-Params-Validate/
Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libmoosex-params-validate-perl/
Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libmoosex-params-validate-perl/
Modified: trunk/libmoosex-params-validate-perl/lib/MooseX/Params/Validate.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-params-validate-perl/lib/MooseX/Params/Validate.pm?rev=47933&op=diff
==============================================================================
--- trunk/libmoosex-params-validate-perl/lib/MooseX/Params/Validate.pm (original)
+++ trunk/libmoosex-params-validate-perl/lib/MooseX/Params/Validate.pm Mon Nov 30 02:44:11 2009
@@ -19,7 +19,7 @@
},
};
-our $VERSION = '0.12';
+our $VERSION = '0.13';
our $AUTHORITY = 'cpan:STEVAN';
my %CACHED_SPECS;
@@ -52,7 +52,7 @@
my %args = @$args;
$args{$_} = $spec{$_}{constraint}->coerce( $args{$_} )
- for grep { $spec{$_}{coerce} } keys %spec;
+ for grep { $spec{$_}{coerce} && exists $args{$_} } keys %spec;
%args = Params::Validate::validate_with(
params => \%args,
@@ -146,7 +146,7 @@
my @args = @{$args};
$args[$_] = $pv_spec[$_]{constraint}->coerce( $args[$_] )
- for grep { $pv_spec[$_]{coerce} } 0 .. $#pv_spec;
+ for grep { $pv_spec[$_] && $pv_spec[$_]{coerce} } 0 .. $#args;
@args = Params::Validate::validate_with(
params => \@args,
Modified: trunk/libmoosex-params-validate-perl/t/005_coercion.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmoosex-params-validate-perl/t/005_coercion.t?rev=47933&op=diff
==============================================================================
--- trunk/libmoosex-params-validate-perl/t/005_coercion.t (original)
+++ trunk/libmoosex-params-validate-perl/t/005_coercion.t Mon Nov 30 02:44:11 2009
@@ -3,9 +3,11 @@
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 15;
use Test::Exception;
+# Note that setting coerce => 1 for the Num type tests that we don't try to do
+# coercions for a type which doesn't have any coercions.
{
package Foo;
use Moose;
@@ -27,6 +29,19 @@
[ $params{size1}, $params{size2}, $params{number} ];
}
+ # added to test 'optional' on validated_hash
+ sub baropt {
+ my $self = shift;
+ my %params = validated_hash(
+ \@_,
+ size1 => { isa => 'Size', coerce => 1, optional => 1 },
+ size2 => { isa => 'Size', coerce => 0, optional => 1 },
+ number => { isa => 'Num', coerce => 1, optional => 1 },
+ );
+ [ $params{size1}, $params{size2}, $params{number} ];
+ }
+
+
sub baz {
my $self = shift;
my ( $size1, $size2, $number ) = validated_list(
@@ -46,6 +61,17 @@
size1 => { isa => 'Size', coerce => 1, optional => 1 },
size2 => { isa => 'Size', coerce => 0, optional => 1 },
number => { isa => 'Num', coerce => 1, optional => 1 },
+ );
+ [ $size1, $size2, $number ];
+ }
+
+ sub ran_out {
+ my $self = shift;
+ my ( $size1, $size2, $number ) = pos_validated_list(
+ \@_,
+ { isa => 'Size', coerce => 1, optional => 1 },
+ { isa => 'Size', coerce => 0, optional => 1 },
+ { isa => 'Num', coerce => 1, optional => 1 },
);
[ $size1, $size2, $number ];
}
@@ -72,7 +98,7 @@
throws_ok { $foo->bar( size1 => 30, size2 => 10, number => 'something' ) }
qr/\QThe 'number' parameter/,
- '... the number param cannot be coerced';
+ '... the number param cannot be coerced because there is no coercion defined for Num';
is_deeply(
$foo->baz( size1 => 10, size2 => 20, number => 30 ),
@@ -95,7 +121,36 @@
'... the number param cannot be coerced';
is_deeply(
+ $foo->baropt( size2 => 4 ),
+ [ undef, 4, undef ],
+ '... validated_hash does not try to coerce keys which are not provided'
+);
+
+is_deeply(
$foo->quux( size2 => 4 ),
[ undef, 4, undef ],
- '... does not try to coerce keys which are not provided'
+ '... validated_list does not try to coerce keys which are not provided'
);
+
+is_deeply(
+ $foo->ran_out( 1, 2, 3 ),
+ [ 1, 2, 3 ],
+ 'got the return value right without coercions'
+);
+
+is_deeply(
+ $foo->ran_out( [1], 2, 3 ),
+ [ 1, 2, 3 ],
+ 'got the return value right with coercion for the first param'
+);
+
+throws_ok { $foo->ran_out( [ 1, 2 ], [ 1, 2 ] ) }
+qr/\QParameter #2/,
+ '... did not attempt to coerce the second parameter';
+
+
+is_deeply(
+ $foo->ran_out(),
+ [ undef, undef, undef ],
+ 'did not try to coerce non-existent parameters'
+);
More information about the Pkg-perl-cvs-commits
mailing list