[Moose-commits] r7458 - MooseX-Params-Validate/trunk/t
autarch at code2.0beta.co.uk
autarch at code2.0beta.co.uk
Sat Jan 31 22:33:41 GMT 2009
Author: autarch
Date: 2009-01-31 14:33:41 -0800 (Sat, 31 Jan 2009)
New Revision: 7458
Modified:
MooseX-Params-Validate/trunk/t/001_basic.t
MooseX-Params-Validate/trunk/t/002_basic_positional.t
MooseX-Params-Validate/trunk/t/003_nocache_flag.t
MooseX-Params-Validate/trunk/t/004_custom_cache_key.t
MooseX-Params-Validate/trunk/t/005_coercion.t
MooseX-Params-Validate/trunk/t/006_not_moose.t
Log:
tidy all the test files
Modified: MooseX-Params-Validate/trunk/t/001_basic.t
===================================================================
--- MooseX-Params-Validate/trunk/t/001_basic.t 2009-01-31 22:28:43 UTC (rev 7457)
+++ MooseX-Params-Validate/trunk/t/001_basic.t 2009-01-31 22:33:41 UTC (rev 7458)
@@ -6,109 +6,143 @@
use Test::More tests => 33;
use Test::Exception;
-
{
package Roles::Blah;
use Moose::Role;
use MooseX::Params::Validate;
-
+
requires 'bar';
- requires 'baz';
-
+ requires 'baz';
+
sub foo {
- my ($self, %params) = validate(\@_,
+ my ( $self, %params ) = validate(
+ \@_,
bar => { isa => 'Str', default => 'Moose' },
);
return "Horray for $params{bar}!";
- }
-
+ }
+
package Foo;
use Moose;
use Moose::Util::TypeConstraints;
use MooseX::Params::Validate;
with 'Roles::Blah';
-
+
sub bar {
my $self = shift;
- my %params = validate(\@_,
- foo => { isa => 'Foo' },
- baz => { isa => 'ArrayRef | HashRef', optional => 1 },
- gorch => { isa => 'ArrayRef[Int]', optional => 1 },
+ my %params = validate(
+ \@_,
+ foo => { isa => 'Foo' },
+ baz => { isa => 'ArrayRef | HashRef', optional => 1 },
+ gorch => { isa => 'ArrayRef[Int]', optional => 1 },
);
[ $params{foo}, $params{baz}, $params{gorch} ];
- }
-
+ }
+
sub baz {
my $self = shift;
- my %params = validate(\@_,
- foo => { isa => subtype('Object' => where { $_->isa('Foo') }), optional => 1 },
- bar => { does => 'Roles::Blah', optional => 1 },
- boo => { does => subtype('Role' => where { $_->does('Roles::Blah') }), optional => 1 },
+ my %params = validate(
+ \@_,
+ foo => {
+ isa => subtype( 'Object' => where { $_->isa('Foo') } ),
+ optional => 1
+ },
+ bar => { does => 'Roles::Blah', optional => 1 },
+ boo => {
+ does =>
+ subtype( 'Role' => where { $_->does('Roles::Blah') } ),
+ optional => 1
+ },
);
return $params{foo} || $params{bar} || $params{boo};
- }
+ }
}
-
my $foo = Foo->new;
-isa_ok($foo, 'Foo');
+isa_ok( $foo, 'Foo' );
-is($foo->foo, 'Horray for Moose!', '... got the right return value');
-is($foo->foo(bar => 'Rolsky'), 'Horray for Rolsky!', '... got the right return value');
+is( $foo->foo, 'Horray for Moose!', '... got the right return value' );
+is( $foo->foo( bar => 'Rolsky' ), 'Horray for Rolsky!',
+ '... got the right return value' );
-is($foo->baz(foo => $foo), $foo, '... foo param must be a Foo instance');
+is( $foo->baz( foo => $foo ), $foo, '... foo param must be a Foo instance' );
-dies_ok { $foo->baz(foo => 10) } '... the foo param in &baz must be a Foo instance';
-dies_ok { $foo->baz(foo => "foo") } '... the foo param in &baz must be a Foo instance';
-dies_ok { $foo->baz(foo => []) } '... the foo param in &baz must be a Foo instance';
+dies_ok { $foo->baz( foo => 10 ) }
+'... the foo param in &baz must be a Foo instance';
+dies_ok { $foo->baz( foo => "foo" ) }
+'... the foo param in &baz must be a Foo instance';
+dies_ok { $foo->baz( foo => [] ) }
+'... the foo param in &baz must be a Foo instance';
-is($foo->baz(bar => $foo), $foo, '... bar param must do Roles::Blah');
+is( $foo->baz( bar => $foo ), $foo, '... bar param must do Roles::Blah' );
-dies_ok { $foo->baz(bar => 10) } '... the bar param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz(bar => "foo") } '... the bar param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz(bar => []) } '... the bar param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( bar => 10 ) }
+'... the bar param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( bar => "foo" ) }
+'... the bar param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( bar => [] ) }
+'... the bar param in &baz must be do Roles::Blah';
-is($foo->baz(boo => $foo), $foo, '... boo param must do Roles::Blah');
+is( $foo->baz( boo => $foo ), $foo, '... boo param must do Roles::Blah' );
-dies_ok { $foo->baz(boo => 10) } '... the boo param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz(boo => "foo") } '... the boo param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz(boo => []) } '... the boo param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( boo => 10 ) }
+'... the boo param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( boo => "foo" ) }
+'... the boo param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( boo => [] ) }
+'... the boo param in &baz must be do Roles::Blah';
-dies_ok { $foo->bar } '... bar has a required params';
-dies_ok { $foo->bar(foo => 10) } '... the foo param in &bar must be a Foo instance';
-dies_ok { $foo->bar(foo => "foo") } '... the foo param in &bar must be a Foo instance';
-dies_ok { $foo->bar(foo => []) } '... the foo param in &bar must be a Foo instance';
-dies_ok { $foo->bar(baz => []) } '... bar has a required foo param';
+dies_ok { $foo->bar } '... bar has a required params';
+dies_ok { $foo->bar( foo => 10 ) }
+'... the foo param in &bar must be a Foo instance';
+dies_ok { $foo->bar( foo => "foo" ) }
+'... the foo param in &bar must be a Foo instance';
+dies_ok { $foo->bar( foo => [] ) }
+'... the foo param in &bar must be a Foo instance';
+dies_ok { $foo->bar( baz => [] ) } '... bar has a required foo param';
is_deeply(
-$foo->bar(foo => $foo),
-[$foo, undef, undef],
-'... the foo param in &bar got a Foo instance');
+ $foo->bar( foo => $foo ),
+ [ $foo, undef, undef ],
+ '... the foo param in &bar got a Foo instance'
+);
is_deeply(
-$foo->bar(foo => $foo, baz => []),
-[$foo, [], undef],
-'... the foo param and baz param in &bar got a correct args');
+ $foo->bar( foo => $foo, baz => [] ),
+ [ $foo, [], undef ],
+ '... the foo param and baz param in &bar got a correct args'
+);
is_deeply(
-$foo->bar(foo => $foo, baz => {}),
-[$foo, {}, undef],
-'... the foo param and baz param in &bar got a correct args');
+ $foo->bar( foo => $foo, baz => {} ),
+ [ $foo, {}, undef ],
+ '... the foo param and baz param in &bar got a correct args'
+);
-dies_ok { $foo->bar(foo => $foo, baz => undef) } '... baz requires a ArrayRef | HashRef';
-dies_ok { $foo->bar(foo => $foo, baz => 10) } '... baz requires a ArrayRef | HashRef';
-dies_ok { $foo->bar(foo => $foo, baz => 'Foo') } '... baz requires a ArrayRef | HashRef';
-dies_ok { $foo->bar(foo => $foo, baz => \(my $var)) } '... baz requires a ArrayRef | HashRef';
+dies_ok { $foo->bar( foo => $foo, baz => undef ) }
+'... baz requires a ArrayRef | HashRef';
+dies_ok { $foo->bar( foo => $foo, baz => 10 ) }
+'... baz requires a ArrayRef | HashRef';
+dies_ok { $foo->bar( foo => $foo, baz => 'Foo' ) }
+'... baz requires a ArrayRef | HashRef';
+dies_ok { $foo->bar( foo => $foo, baz => \( my $var ) ) }
+'... baz requires a ArrayRef | HashRef';
is_deeply(
-$foo->bar(foo => $foo, gorch => [1, 2, 3]),
-[$foo, undef, [1, 2, 3]],
-'... the foo param in &bar got a Foo instance');
+ $foo->bar( foo => $foo, gorch => [ 1, 2, 3 ] ),
+ [ $foo, undef, [ 1, 2, 3 ] ],
+ '... the foo param in &bar got a Foo instance'
+);
-dies_ok { $foo->bar(foo => $foo, gorch => undef) } '... gorch requires a ArrayRef[Int]';
-dies_ok { $foo->bar(foo => $foo, gorch => 10) } '... gorch requires a ArrayRef[Int]';
-dies_ok { $foo->bar(foo => $foo, gorch => 'Foo') } '... gorch requires a ArrayRef[Int]';
-dies_ok { $foo->bar(foo => $foo, gorch => \(my $var)) } '... gorch requires a ArrayRef[Int]';
-dies_ok { $foo->bar(foo => $foo, gorch => [qw/one two three/]) } '... gorch requires a ArrayRef[Int]';
+dies_ok { $foo->bar( foo => $foo, gorch => undef ) }
+'... gorch requires a ArrayRef[Int]';
+dies_ok { $foo->bar( foo => $foo, gorch => 10 ) }
+'... gorch requires a ArrayRef[Int]';
+dies_ok { $foo->bar( foo => $foo, gorch => 'Foo' ) }
+'... gorch requires a ArrayRef[Int]';
+dies_ok { $foo->bar( foo => $foo, gorch => \( my $var ) ) }
+'... gorch requires a ArrayRef[Int]';
+dies_ok { $foo->bar( foo => $foo, gorch => [qw/one two three/] ) }
+'... gorch requires a ArrayRef[Int]';
Modified: MooseX-Params-Validate/trunk/t/002_basic_positional.t
===================================================================
--- MooseX-Params-Validate/trunk/t/002_basic_positional.t 2009-01-31 22:28:43 UTC (rev 7457)
+++ MooseX-Params-Validate/trunk/t/002_basic_positional.t 2009-01-31 22:33:41 UTC (rev 7458)
@@ -6,15 +6,14 @@
use Test::More tests => 27;
use Test::Exception;
-
{
package Roles::Blah;
use Moose::Role;
-
+
requires 'foo';
requires 'bar';
- requires 'baz';
-
+ requires 'baz';
+
package Foo;
use Moose;
use Moose::Util::TypeConstraints;
@@ -23,89 +22,108 @@
with 'Roles::Blah';
sub foo {
- my ($self, $bar) = validatep(\@_,
+ my ( $self, $bar ) = validatep(
+ \@_,
bar => { isa => 'Str', default => 'Moose' },
);
return "Horray for $bar!";
}
-
+
sub bar {
my $self = shift;
- my ($foo, $baz) = validatep(\@_,
- foo => { isa => 'Foo' },
- baz => { isa => 'ArrayRef | HashRef', optional => 1 },
+ my ( $foo, $baz ) = validatep(
+ \@_,
+ foo => { isa => 'Foo' },
+ baz => { isa => 'ArrayRef | HashRef', optional => 1 },
);
[ $foo, $baz ];
- }
-
+ }
+
sub baz {
my $self = shift;
- my ($foo, $bar, $boo) = validatep(\@_,
- foo => { isa => subtype('Object' => where { $_->isa('Foo') }), optional => 1 },
- bar => { does => 'Roles::Blah', optional => 1 },
- boo => { does => subtype('Role' => where { $_->does('Roles::Blah') }), optional => 1 },
+ my ( $foo, $bar, $boo ) = validatep(
+ \@_,
+ foo => {
+ isa => subtype( 'Object' => where { $_->isa('Foo') } ),
+ optional => 1
+ },
+ bar => { does => 'Roles::Blah', optional => 1 },
+ boo => {
+ does =>
+ subtype( 'Role' => where { $_->does('Roles::Blah') } ),
+ optional => 1
+ },
);
return $foo || $bar || $boo;
- }
+ }
}
-
my $foo = Foo->new;
-isa_ok($foo, 'Foo');
+isa_ok( $foo, 'Foo' );
-is($foo->foo, 'Horray for Moose!', '... got the right return value');
-is($foo->foo(bar => 'Rolsky'), 'Horray for Rolsky!', '... got the right return value');
+is( $foo->foo, 'Horray for Moose!', '... got the right return value' );
+is( $foo->foo( bar => 'Rolsky' ), 'Horray for Rolsky!',
+ '... got the right return value' );
-is($foo->baz(foo => $foo), $foo, '... foo param must be a Foo instance');
+is( $foo->baz( foo => $foo ), $foo, '... foo param must be a Foo instance' );
-dies_ok { $foo->baz(foo => 10) } '... the foo param in &baz must be a Foo instance';
-dies_ok { $foo->baz(foo => "foo") } '... the foo param in &baz must be a Foo instance';
-dies_ok { $foo->baz(foo => []) } '... the foo param in &baz must be a Foo instance';
+dies_ok { $foo->baz( foo => 10 ) }
+'... the foo param in &baz must be a Foo instance';
+dies_ok { $foo->baz( foo => "foo" ) }
+'... the foo param in &baz must be a Foo instance';
+dies_ok { $foo->baz( foo => [] ) }
+'... the foo param in &baz must be a Foo instance';
-is($foo->baz(bar => $foo), $foo, '... bar param must do Roles::Blah');
+is( $foo->baz( bar => $foo ), $foo, '... bar param must do Roles::Blah' );
-dies_ok { $foo->baz(bar => 10) } '... the bar param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz(bar => "foo") } '... the bar param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz(bar => []) } '... the bar param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( bar => 10 ) }
+'... the bar param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( bar => "foo" ) }
+'... the bar param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( bar => [] ) }
+'... the bar param in &baz must be do Roles::Blah';
-is($foo->baz(boo => $foo), $foo, '... boo param must do Roles::Blah');
+is( $foo->baz( boo => $foo ), $foo, '... boo param must do Roles::Blah' );
-dies_ok { $foo->baz(boo => 10) } '... the boo param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz(boo => "foo") } '... the boo param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz(boo => []) } '... the boo param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( boo => 10 ) }
+'... the boo param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( boo => "foo" ) }
+'... the boo param in &baz must be do Roles::Blah';
+dies_ok { $foo->baz( boo => [] ) }
+'... the boo param in &baz must be do Roles::Blah';
-dies_ok { $foo->bar } '... bar has a required params';
-dies_ok { $foo->bar(foo => 10) } '... the foo param in &bar must be a Foo instance';
-dies_ok { $foo->bar(foo => "foo") } '... the foo param in &bar must be a Foo instance';
-dies_ok { $foo->bar(foo => []) } '... the foo param in &bar must be a Foo instance';
-dies_ok { $foo->bar(baz => []) } '... bar has a required foo param';
+dies_ok { $foo->bar } '... bar has a required params';
+dies_ok { $foo->bar( foo => 10 ) }
+'... the foo param in &bar must be a Foo instance';
+dies_ok { $foo->bar( foo => "foo" ) }
+'... the foo param in &bar must be a Foo instance';
+dies_ok { $foo->bar( foo => [] ) }
+'... the foo param in &bar must be a Foo instance';
+dies_ok { $foo->bar( baz => [] ) } '... bar has a required foo param';
is_deeply(
-$foo->bar(foo => $foo),
-[$foo, undef],
-'... the foo param in &bar got a Foo instance');
+ $foo->bar( foo => $foo ),
+ [ $foo, undef ],
+ '... the foo param in &bar got a Foo instance'
+);
is_deeply(
-$foo->bar(foo => $foo, baz => []),
-[$foo, []],
-'... the foo param and baz param in &bar got a correct args');
+ $foo->bar( foo => $foo, baz => [] ),
+ [ $foo, [] ],
+ '... the foo param and baz param in &bar got a correct args'
+);
is_deeply(
-$foo->bar(foo => $foo, baz => {}),
-[$foo, {}],
-'... the foo param and baz param in &bar got a correct args');
+ $foo->bar( foo => $foo, baz => {} ),
+ [ $foo, {} ],
+ '... the foo param and baz param in &bar got a correct args'
+);
-dies_ok { $foo->bar(foo => $foo, baz => undef) } '... baz requires a ArrayRef | HashRef';
-dies_ok { $foo->bar(foo => $foo, baz => 10) } '... baz requires a ArrayRef | HashRef';
-dies_ok { $foo->bar(foo => $foo, baz => 'Foo') } '... baz requires a ArrayRef | HashRef';
-dies_ok { $foo->bar(foo => $foo, baz => \(my $var)) } '... baz requires a ArrayRef | HashRef';
-
-
-
-
-
-
-
-
-
-
+dies_ok { $foo->bar( foo => $foo, baz => undef ) }
+'... baz requires a ArrayRef | HashRef';
+dies_ok { $foo->bar( foo => $foo, baz => 10 ) }
+'... baz requires a ArrayRef | HashRef';
+dies_ok { $foo->bar( foo => $foo, baz => 'Foo' ) }
+'... baz requires a ArrayRef | HashRef';
+dies_ok { $foo->bar( foo => $foo, baz => \( my $var ) ) }
+'... baz requires a ArrayRef | HashRef';
Modified: MooseX-Params-Validate/trunk/t/003_nocache_flag.t
===================================================================
--- MooseX-Params-Validate/trunk/t/003_nocache_flag.t 2009-01-31 22:28:43 UTC (rev 7457)
+++ MooseX-Params-Validate/trunk/t/003_nocache_flag.t 2009-01-31 22:33:41 UTC (rev 7458)
@@ -10,27 +10,29 @@
package Foo;
use Moose;
use MooseX::Params::Validate;
-
+
sub bar {
- my ($self, $args, $params) = @_;
+ my ( $self, $args, $params ) = @_;
$params->{MX_PARAMS_VALIDATE_NO_CACHE}++;
- return validate($args, %$params);
+ return validate( $args, %$params );
}
}
my $foo = Foo->new;
-isa_ok($foo, 'Foo');
+isa_ok( $foo, 'Foo' );
lives_ok {
- $foo->bar([ baz => 1 ], { baz => { isa => 'Int' } });
-} '... successfully applied the parameter validation';
+ $foo->bar( [ baz => 1 ], { baz => { isa => 'Int' } } );
+}
+'... successfully applied the parameter validation';
lives_ok {
- $foo->bar([ baz => [ 1, 2, 3 ] ], { baz => { isa => 'ArrayRef' } });
-} '... successfully applied the parameter validation (look mah no cache)';
+ $foo->bar( [ baz => [ 1, 2, 3 ] ], { baz => { isa => 'ArrayRef' } } );
+}
+'... successfully applied the parameter validation (look mah no cache)';
lives_ok {
- $foo->bar([ baz => { one => 1 } ], { baz => { isa => 'HashRef' } });
-} '... successfully applied the parameter validation (look mah no cache) (just checkin)';
+ $foo->bar( [ baz => { one => 1 } ], { baz => { isa => 'HashRef' } } );
+}
+'... successfully applied the parameter validation (look mah no cache) (just checkin)';
-
Modified: MooseX-Params-Validate/trunk/t/004_custom_cache_key.t
===================================================================
--- MooseX-Params-Validate/trunk/t/004_custom_cache_key.t 2009-01-31 22:28:43 UTC (rev 7457)
+++ MooseX-Params-Validate/trunk/t/004_custom_cache_key.t 2009-01-31 22:33:41 UTC (rev 7458)
@@ -11,39 +11,43 @@
package Foo;
use Moose;
use MooseX::Params::Validate;
-
+
sub bar {
- my ($self, $args, $params) = @_;
- $params->{MX_PARAMS_VALIDATE_CACHE_KEY} = Scalar::Util::refaddr($self);
- return validate($args, %$params);
+ my ( $self, $args, $params ) = @_;
+ $params->{MX_PARAMS_VALIDATE_CACHE_KEY}
+ = Scalar::Util::refaddr($self);
+ return validate( $args, %$params );
}
}
my $foo = Foo->new;
-isa_ok($foo, 'Foo');
+isa_ok( $foo, 'Foo' );
lives_ok {
- $foo->bar([ baz => 1 ], { baz => { isa => 'Int' } });
-} '... successfully applied the parameter validation';
+ $foo->bar( [ baz => 1 ], { baz => { isa => 'Int' } } );
+}
+'... successfully applied the parameter validation';
dies_ok {
- $foo->bar([ baz => [ 1, 2, 3 ] ], { baz => { isa => 'ArrayRef' } });
-} '... successfully re-used the parameter validation for this instance';
+ $foo->bar( [ baz => [ 1, 2, 3 ] ], { baz => { isa => 'ArrayRef' } } );
+}
+'... successfully re-used the parameter validation for this instance';
my $foo2 = Foo->new;
-isa_ok($foo2, 'Foo');
+isa_ok( $foo2, 'Foo' );
lives_ok {
- $foo2->bar([ baz => [ 1, 2, 3 ] ], { baz => { isa => 'ArrayRef' } });
-} '... successfully applied the parameter validation';
+ $foo2->bar( [ baz => [ 1, 2, 3 ] ], { baz => { isa => 'ArrayRef' } } );
+}
+'... successfully applied the parameter validation';
dies_ok {
- $foo2->bar([ baz => 1 ], { baz => { isa => 'Int' } });
-} '... successfully re-used the parameter validation for this instance';
+ $foo2->bar( [ baz => 1 ], { baz => { isa => 'Int' } } );
+}
+'... successfully re-used the parameter validation for this instance';
lives_ok {
- $foo->bar([ baz => 1 ], { baz => { isa => 'Int' } });
-} '... successfully applied the parameter validation (just checking)';
+ $foo->bar( [ baz => 1 ], { baz => { isa => 'Int' } } );
+}
+'... successfully applied the parameter validation (just checking)';
-
-
Modified: MooseX-Params-Validate/trunk/t/005_coercion.t
===================================================================
--- MooseX-Params-Validate/trunk/t/005_coercion.t 2009-01-31 22:28:43 UTC (rev 7457)
+++ MooseX-Params-Validate/trunk/t/005_coercion.t 2009-01-31 22:33:41 UTC (rev 7458)
@@ -12,17 +12,14 @@
use Moose::Util::TypeConstraints;
use MooseX::Params::Validate;
- subtype 'Size'
- => as 'Int'
- => where { $_ >= 0 };
+ subtype 'Size' => as 'Int' => where { $_ >= 0 };
- coerce 'Size'
- => from 'ArrayRef'
- => via { scalar @{ $_ } };
+ coerce 'Size' => from 'ArrayRef' => via { scalar @{$_} };
sub bar {
my $self = shift;
- my %params = validate(\@_,
+ my %params = validate(
+ \@_,
size1 => { isa => 'Size', coerce => 1 },
size2 => { isa => 'Size', coerce => 0 },
number => { isa => 'Num', coerce => 1 },
@@ -31,8 +28,9 @@
}
sub baz {
- my $self = shift;
- my ( $size1, $size2, $number ) = validatep(\@_,
+ my $self = shift;
+ my ( $size1, $size2, $number ) = validatep(
+ \@_,
size1 => { isa => 'Size', coerce => 1 },
size2 => { isa => 'Size', coerce => 0 },
number => { isa => 'Num', coerce => 1 },
@@ -41,42 +39,41 @@
}
}
-
my $foo = Foo->new;
-isa_ok($foo, 'Foo');
+isa_ok( $foo, 'Foo' );
is_deeply(
-$foo->bar( size1 => 10, size2 => 20, number => 30 ),
-[ 10, 20, 30 ],
-'got the return value right without coercions');
+ $foo->bar( size1 => 10, size2 => 20, number => 30 ),
+ [ 10, 20, 30 ],
+ 'got the return value right without coercions'
+);
is_deeply(
-$foo->bar( size1 => [ 1, 2, 3 ], size2 => 20, number => 30 ),
-[ 3, 20, 30 ],
-'got the return value right with coercions for size1');
+ $foo->bar( size1 => [ 1, 2, 3 ], size2 => 20, number => 30 ),
+ [ 3, 20, 30 ],
+ 'got the return value right with coercions for size1'
+);
-dies_ok
-{ $foo->bar( size1 => 30, size2 => [ 1, 2, 3], number => 30 ) }
+dies_ok { $foo->bar( size1 => 30, size2 => [ 1, 2, 3 ], number => 30 ) }
'... the size2 param cannot be coerced';
-dies_ok
-{ $foo->bar( size1 => 30, size2 => 10, number => 'something' ) }
+dies_ok { $foo->bar( size1 => 30, size2 => 10, number => 'something' ) }
'... the number param cannot be coerced';
is_deeply(
-$foo->baz( size1 => 10, size2 => 20, number => 30 ),
-[ 10, 20, 30 ],
-'got the return value right without coercions');
+ $foo->baz( size1 => 10, size2 => 20, number => 30 ),
+ [ 10, 20, 30 ],
+ 'got the return value right without coercions'
+);
is_deeply(
-$foo->baz( size1 => [ 1, 2, 3 ], size2 => 20, number => 30 ),
-[ 3, 20, 30 ],
-'got the return value right with coercions for size1');
+ $foo->baz( size1 => [ 1, 2, 3 ], size2 => 20, number => 30 ),
+ [ 3, 20, 30 ],
+ 'got the return value right with coercions for size1'
+);
-dies_ok
-{ $foo->baz( size1 => 30, size2 => [ 1, 2, 3], number => 30 ) }
+dies_ok { $foo->baz( size1 => 30, size2 => [ 1, 2, 3 ], number => 30 ) }
'... the size2 param cannot be coerced';
-dies_ok
-{ $foo->baz( size1 => 30, size2 => 10, number => 'something' ) }
+dies_ok { $foo->baz( size1 => 30, size2 => 10, number => 'something' ) }
'... the number param cannot be coerced';
Modified: MooseX-Params-Validate/trunk/t/006_not_moose.t
===================================================================
--- MooseX-Params-Validate/trunk/t/006_not_moose.t 2009-01-31 22:28:43 UTC (rev 7457)
+++ MooseX-Params-Validate/trunk/t/006_not_moose.t 2009-01-31 22:33:41 UTC (rev 7458)
@@ -13,6 +13,8 @@
}
EOF
-is( $@, '',
- 'loading MX::Params::Validate in a non-Moose class does not blow up' );
+is(
+ $@, '',
+ 'loading MX::Params::Validate in a non-Moose class does not blow up'
+);
ok( Foo->can('validate'), 'validate() sub was added to Foo package' );
More information about the Moose-commits
mailing list