[Bast-commits] r9588 - Class-C3-Componentised/branches/apply_actions/t

frew at dev.catalyst.perl.org frew at dev.catalyst.perl.org
Wed Jun 23 15:34:43 GMT 2010


Author: frew
Date: 2010-06-23 16:34:43 +0100 (Wed, 23 Jun 2010)
New Revision: 9588

Modified:
   Class-C3-Componentised/branches/apply_actions/t/03-on-apply.t
Log:
test to ensure that *_APPLY works with die and loading other components

Modified: Class-C3-Componentised/branches/apply_actions/t/03-on-apply.t
===================================================================
--- Class-C3-Componentised/branches/apply_actions/t/03-on-apply.t	2010-06-23 15:34:01 UTC (rev 9587)
+++ Class-C3-Componentised/branches/apply_actions/t/03-on-apply.t	2010-06-23 15:34:43 UTC (rev 9588)
@@ -3,6 +3,7 @@
 
 use FindBin;
 use Test::More;
+use Test::Exception;
 
 use lib "$FindBin::Bin/lib";
 
@@ -21,12 +22,44 @@
   1;
 }
 
+BEGIN {
+  package MyModule::Plugin::TestActionDie;
+
+  use Class::C3::Componentised::LoadActions;
+
+  BEFORE_APPLY { die 'this component is not applicable (yuk yuk yuk)' };
+
+  1;
+}
+
+BEGIN {
+  package MyModule::Plugin::TestActionLoadFrew;
+
+  use Class::C3::Componentised::LoadActions;
+
+  BEFORE_APPLY { $_[0]->load_components('TestActionFrew') };
+
+  1;
+}
+
+BEGIN {
+  package MyModule::Plugin::TestActionFrew;
+  sub frew { 1 }
+  1;
+}
+
 use_ok('MyModule');
-is $first, 0, 'first starts at zero';
-is $last, 0, 'last starts at zero';
+is( $first, 0, 'first starts at zero' );
+is( $last, 0, 'last starts at zero' );
 
 MyModule->load_components('TestActions');
-is $first, 1, 'first gets value of 1 (it runs first)';
-is $last, 2, 'last gets value of 2 (it runs last)';
+is( $first, 1, 'first gets value of 1 (it runs first)' );
+is( $last, 2, 'last gets value of 2 (it runs last)' );
 
+dies_ok { MyModule->load_components('TestActionDie') } 'die from BEFORE_APPLY works';
+
+dies_ok { MyModule->frew } 'fREW is not loaded';
+MyModule->load_components('TestActionLoadFrew');
+is( MyModule->frew, 1, 'fREW is loaded' );
+
 done_testing;




More information about the Bast-commits mailing list