[Moose-commits] r7468 - MooseX-Params-Validate/trunk/t

autarch at code2.0beta.co.uk autarch at code2.0beta.co.uk
Sun Feb 1 15:40:20 GMT 2009


Author: autarch
Date: 2009-02-01 07:40:20 -0800 (Sun, 01 Feb 2009)
New Revision: 7468

Modified:
   MooseX-Params-Validate/trunk/t/002_basic_list.t
Log:
Use throws_ok to check the error message


Modified: MooseX-Params-Validate/trunk/t/002_basic_list.t
===================================================================
--- MooseX-Params-Validate/trunk/t/002_basic_list.t	2009-02-01 15:38:54 UTC (rev 7467)
+++ MooseX-Params-Validate/trunk/t/002_basic_list.t	2009-02-01 15:40:20 UTC (rev 7468)
@@ -67,39 +67,41 @@
 
 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';
+throws_ok { $foo->baz( foo => 10 ) } qr/\QThe 'foo' parameter ("10")/,
+    '... the foo param in &baz must be a Foo instance';
+throws_ok { $foo->baz( foo => "foo" ) } qr/\QThe 'foo' parameter ("foo")/,
+    '... the foo param in &baz must be a Foo instance';
+throws_ok { $foo->baz( foo => [] ) } qr/\QThe 'foo' parameter/,
+    '... the foo param in &baz must be a Foo instance';
 
 is( $foo->baz( bar => $foo ), $foo, '... bar param must do Roles::Blah' );
 
-dies_ok { $foo->baz( bar => 10 ) }
+throws_ok { $foo->baz( bar => 10 ) } qr/\QThe 'bar' parameter ("10")/,
 '... the bar param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz( bar => "foo" ) }
+throws_ok { $foo->baz( bar => "foo" ) } qr/\QThe 'bar' parameter ("foo")/,
 '... the bar param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz( bar => [] ) }
+throws_ok { $foo->baz( bar => [] ) } qr/\QThe 'bar' parameter/,
 '... the bar param in &baz must be do Roles::Blah';
 
 is( $foo->baz( boo => $foo ), $foo, '... boo param must do Roles::Blah' );
 
-dies_ok { $foo->baz( boo => 10 ) }
+throws_ok { $foo->baz( boo => 10 ) } qr/\QThe 'boo' parameter ("10")/,
 '... the boo param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz( boo => "foo" ) }
+throws_ok { $foo->baz( boo => "foo" ) } qr/\QThe 'boo' parameter ("foo")/,
 '... the boo param in &baz must be do Roles::Blah';
-dies_ok { $foo->baz( boo => [] ) }
+throws_ok { $foo->baz( boo => [] ) } qr/\QThe 'boo' parameter/,
 '... 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';
+throws_ok { $foo->bar } qr/\QMandatory parameter 'foo'/,
+    '... bar has a required param';
+throws_ok { $foo->bar( foo => 10 ) } qr/\QThe 'foo' parameter ("10")/,
+    '... the foo param in &bar must be a Foo instance';
+throws_ok { $foo->bar( foo => "foo" ) } qr/\QThe 'foo' parameter ("foo")/,
+    '... the foo param in &bar must be a Foo instance';
+throws_ok { $foo->bar( foo => [] ) } qr/\QThe 'foo' parameter/,
+    '... the foo param in &bar must be a Foo instance';
+throws_ok { $foo->bar( baz => [] ) } qr/\QMandatory parameter 'foo'/,,
+    '... bar has a required foo param';
 
 is_deeply(
     $foo->bar( foo => $foo ),
@@ -119,11 +121,15 @@
     '... 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';
+throws_ok { $foo->bar( foo => $foo, baz => undef ) }
+qr/\QThe 'baz' parameter (undef)/,
+    '... baz requires a ArrayRef | HashRef';
+throws_ok { $foo->bar( foo => $foo, baz => 10 ) }
+qr/\QThe 'baz' parameter ("10")/,
+    '... baz requires a ArrayRef | HashRef';
+throws_ok { $foo->bar( foo => $foo, baz => 'Foo' ) }
+qr/\QThe 'baz' parameter ("Foo")/,
+    '... baz requires a ArrayRef | HashRef';
+throws_ok { $foo->bar( foo => $foo, baz => \( my $var ) ) }
+qr/\QThe 'baz' parameter/,
+    '... baz requires a ArrayRef | HashRef';




More information about the Moose-commits mailing list