From: Kent Fredric Date: Wed, 22 Jun 2011 05:44:17 +0000 (+1200) Subject: trim excess whitespace X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d32a230232f236f04449c67615e844bee981653a;p=gitmo%2FMoose.git trim excess whitespace --- diff --git a/lib/Moose/Meta/TypeCoercion/Intersection.pm b/lib/Moose/Meta/TypeCoercion/Intersection.pm index a297fc0..b886f81 100644 --- a/lib/Moose/Meta/TypeCoercion/Intersection.pm +++ b/lib/Moose/Meta/TypeCoercion/Intersection.pm @@ -16,27 +16,27 @@ use base 'Moose::Meta::TypeCoercion'; sub compile_type_coercion { my $self = shift; my $type_constraint = $self->type_constraint; - + (blessed $type_constraint && $type_constraint->isa('Moose::Meta::TypeConstraint::Intersection')) || Moose->throw_error("You can only a Moose::Meta::TypeCoercion::Intersection for a " . "Moose::Meta::TypeConstraint::Intersection, not a $type_constraint"); - + $self->_compiled_type_coercion(sub { my $value = shift; - # go through all the type constraints + # go through all the type constraints # in the intersection, and check em ... foreach my $type (@{$type_constraint->type_constraints}) { # if they have a coercion first - if ($type->has_coercion) { + if ($type->has_coercion) { # then try to coerce them ... my $temp = $type->coerce($value); - # and if they get something + # and if they get something # make sure it still fits within # the intersection type ... return $temp if $type_constraint->check($temp); } } - return undef; + return undef; }); } @@ -58,13 +58,13 @@ Moose::Meta::TypeCoercion::Intersection - The Moose Type Coercion metaclass for =head1 DESCRIPTION -For the most part, the only time you will ever encounter an -instance of this class is if you are doing some serious deep -introspection. This API should not be considered final, but -it is B that this will matter to a regular +For the most part, the only time you will ever encounter an +instance of this class is if you are doing some serious deep +introspection. This API should not be considered final, but +it is B that this will matter to a regular Moose user. -If you wish to use features at this depth, please come to the +If you wish to use features at this depth, please come to the #moose IRC channel on irc.perl.org and we can talk :) =head1 METHODS @@ -83,7 +83,7 @@ If you wish to use features at this depth, please come to the =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. @@ -99,6 +99,6 @@ Copyright 2006-2009 by Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +it under the same terms as Perl itself. =cut diff --git a/lib/Moose/Meta/TypeConstraint/Intersection.pm b/lib/Moose/Meta/TypeConstraint/Intersection.pm index 8e71c69..9655bc1 100644 --- a/lib/Moose/Meta/TypeConstraint/Intersection.pm +++ b/lib/Moose/Meta/TypeConstraint/Intersection.pm @@ -18,7 +18,7 @@ __PACKAGE__->meta->add_attribute('type_constraints' => ( default => sub { [] } )); -sub new { +sub new { my ($class, %options) = @_; my $self = $class->SUPER::new( name => (join '&' => sort {$a cmp $b} @@ -82,7 +82,7 @@ sub validate { $message .= ($message ? ' and ' : '') . $err if defined $err; } - return ($message . ' in (' . $self->name . ')') ; + return ($message . ' in (' . $self->name . ')') ; } sub is_a_type_of { @@ -90,7 +90,7 @@ sub is_a_type_of { foreach my $type (@{$self->type_constraints}) { return 1 if $type->is_a_type_of($type_name); } - return 0; + return 0; } sub is_subtype_of { @@ -136,15 +136,15 @@ Moose::Meta::TypeConstraint::Intersection - An intersection of Moose type constr =head1 DESCRIPTION -This metaclass represents an intersection of Moose type constraints. More +This metaclass represents an intersection of Moose type constraints. More details to be explained later (possibly in a Cookbook recipe). -This actually used to be part of Moose::Meta::TypeConstraint, but it -is now better off in it's own file. +This actually used to be part of Moose::Meta::TypeConstraint, but it +is now better off in it's own file. =head1 METHODS -This class is not a subclass of Moose::Meta::TypeConstraint, +This class is not a subclass of Moose::Meta::TypeConstraint, but it does provide the same API =over 4 @@ -167,7 +167,7 @@ but it does provide the same API =back -=head2 Overridden methods +=head2 Overridden methods =over 4 @@ -185,9 +185,9 @@ but it does provide the same API =head2 Empty or Stub methods -These methods tend to not be very relevant in -the context of an intersection. Either that or they are -just difficult to specify and not very useful +These methods tend to not be very relevant in +the context of an intersection. Either that or they are +just difficult to specify and not very useful anyway. They are here for completeness. =over 4 @@ -212,7 +212,7 @@ anyway. They are here for completeness. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 8fb9c64..063439d 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -120,7 +120,7 @@ sub create_type_constraint_intersection { else { @type_constraint_names = @_; } - + (scalar @type_constraint_names >= 2) || __PACKAGE__->_throw_error("You must pass in at least 2 type names to make an intersection"); diff --git a/t/type_constraints/intersection_types.t b/t/type_constraints/intersection_types.t index 3a1c21e..1a84352 100644 --- a/t/type_constraints/intersection_types.t +++ b/t/type_constraints/intersection_types.t @@ -7,7 +7,7 @@ use Test::More tests => 34; use Test::Exception; BEGIN { - use_ok('Moose::Util::TypeConstraints'); + use_ok('Moose::Util::TypeConstraints'); } my $Str = find_type_constraint('Str'); @@ -67,7 +67,7 @@ diag $RefAndArray->validate([]); ok(!defined($RefAndArray->validate([])), '... (ArrayRef & Ref) can accept []'); ok(defined($RefAndArray->validate(undef)), '... (ArrayRef & Ref) cannot accept undef'); -like($RefAndArray->validate(undef), +like($RefAndArray->validate(undef), qr/Validation failed for \'ArrayRef\' with value undef and Validation failed for \'Ref\' with value undef in \(ArrayRef&Ref\)/, '... (ArrayRef & Ref) cannot accept undef'); diff --git a/t/type_constraints/subtyping_intersection_types.t b/t/type_constraints/subtyping_intersection_types.t index c65856c..17189d5 100644 --- a/t/type_constraints/subtyping_intersection_types.t +++ b/t/type_constraints/subtyping_intersection_types.t @@ -31,7 +31,7 @@ lives_ok { } lives_ok { - subtype 'MyCollectionsExtended' + subtype 'MyCollectionsExtended' => as 'ArrayRef&Ref' => where { if (ref($_) eq 'ARRAY') { @@ -54,10 +54,10 @@ lives_ok { is($p->name, 'ArrayRef&Ref', '... parent name is correct'); ok(!$t->check([]), '... validated it correctly'); - ok($t->check([1, 2]), '... validated it correctly'); - - ok($t->check([ one => 1, two => 2 ]), '... validated it correctly'); - + ok($t->check([1, 2]), '... validated it correctly'); + + ok($t->check([ one => 1, two => 2 ]), '... validated it correctly'); + ok(!$t->check(1), '... validated it correctly'); } diff --git a/t/type_constraints/type_notation_parser.t b/t/type_constraints/type_notation_parser.t index 8ceb167..e30f1e9 100644 --- a/t/type_constraints/type_notation_parser.t +++ b/t/type_constraints/type_notation_parser.t @@ -106,45 +106,45 @@ ok(!Moose::Util::TypeConstraints::_detect_type_constraint_union($_), ## now for the intersections -ok(Moose::Util::TypeConstraints::_detect_type_constraint_intersection($_), +ok(Moose::Util::TypeConstraints::_detect_type_constraint_intersection($_), '... this correctly detected intersection (' . $_ . ')') for ( 'Int & Str', - 'Int&Str', + 'Int&Str', 'ArrayRef[Foo] & Int', - 'ArrayRef[Foo]&Int', + 'ArrayRef[Foo]&Int', 'Int & ArrayRef[Foo]', - 'Int&ArrayRef[Foo]', + 'Int&ArrayRef[Foo]', 'ArrayRef[Foo | Int] & Str', - 'ArrayRef[Foo|Int]&Str', - 'Str & ArrayRef[Foo | Int]', - 'Str&ArrayRef[Foo|Int]', - 'Some&Silly&Name&With&Pipes & Int', - 'Some&Silly&Name&With&Pipes&Int', + 'ArrayRef[Foo|Int]&Str', + 'Str & ArrayRef[Foo | Int]', + 'Str&ArrayRef[Foo|Int]', + 'Some&Silly&Name&With&Pipes & Int', + 'Some&Silly&Name&With&Pipes&Int', ); -ok(!Moose::Util::TypeConstraints::_detect_type_constraint_intersection($_), +ok(!Moose::Util::TypeConstraints::_detect_type_constraint_intersection($_), '... this correctly detected a non-intersection (' . $_ . ')') for ( 'Int', 'ArrayRef[Foo | Int]', - 'ArrayRef[Foo|Int]', + 'ArrayRef[Foo|Int]', ); { my %split_tests = ( 'Int & Str' => [ 'Int', 'Str' ], - 'Int&Str' => [ 'Int', 'Str' ], + 'Int&Str' => [ 'Int', 'Str' ], 'ArrayRef[Foo] & Int' => [ 'ArrayRef[Foo]', 'Int' ], - 'ArrayRef[Foo]&Int' => [ 'ArrayRef[Foo]', 'Int' ], + 'ArrayRef[Foo]&Int' => [ 'ArrayRef[Foo]', 'Int' ], 'Int & ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ], - 'Int&ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ], + 'Int&ArrayRef[Foo]' => [ 'Int', 'ArrayRef[Foo]' ], 'ArrayRef[Foo | Int] & Str' => [ 'ArrayRef[Foo | Int]', 'Str' ], - 'ArrayRef[Foo|Int]&Str' => [ 'ArrayRef[Foo|Int]', 'Str' ], - 'Str & ArrayRef[Foo | Int]' => [ 'Str', 'ArrayRef[Foo | Int]' ], - 'Str&ArrayRef[Foo|Int]' => [ 'Str', 'ArrayRef[Foo|Int]' ], - 'Some&Silly&Name&With&Pipes & Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ], - 'Some&Silly&Name&With&Pipes&Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ], + 'ArrayRef[Foo|Int]&Str' => [ 'ArrayRef[Foo|Int]', 'Str' ], + 'Str & ArrayRef[Foo | Int]' => [ 'Str', 'ArrayRef[Foo | Int]' ], + 'Str&ArrayRef[Foo|Int]' => [ 'Str', 'ArrayRef[Foo|Int]' ], + 'Some&Silly&Name&With&Pipes & Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ], + 'Some&Silly&Name&With&Pipes&Int' => [ 'Some', 'Silly', 'Name', 'With', 'Pipes', 'Int' ], ); is_deeply(