fix for prototype undecl issue when type constraint utils loaded before consumers...
[gitmo/Moose.git] / t / 012_super_and_override.t
index 9b5fd9c..e04eea5 100644 (file)
@@ -3,7 +3,8 @@
 use strict;
 use warnings;
 
-use Test::More tests => 16;
+use Test::More tests => 17;
+use Test::Exception;
 
 BEGIN {
     use_ok('Moose');           
@@ -11,8 +12,6 @@ BEGIN {
 
 {
     package Foo;
-    use strict;
-    use warnings;
     use Moose;
     
     sub foo { 'Foo::foo' }
@@ -20,8 +19,6 @@ BEGIN {
     sub baz { 'Foo::baz' }
     
     package Bar;
-    use strict;
-    use warnings;
     use Moose;
     
     extends 'Foo';
@@ -29,14 +26,14 @@ BEGIN {
     override bar => sub { 'Bar::bar -> ' . super() };   
     
     package Baz;
-    use strict;
-    use warnings;
     use Moose;
     
     extends 'Bar';
     
     override bar => sub { 'Baz::bar -> ' . super() };       
     override baz => sub { 'Baz::baz -> ' . super() }; 
+
+    no Moose; # ensure super() still works after unimport
 }
 
 my $baz = Baz->new();
@@ -61,4 +58,26 @@ isa_ok($foo, 'Foo');
 
 is($foo->foo(), 'Foo::foo', '... got the right value from &foo');
 is($foo->bar(), 'Foo::bar', '... got the right value from &bar');
-is($foo->baz(), 'Foo::baz', '... got the right value from &baz');
\ No newline at end of file
+is($foo->baz(), 'Foo::baz', '... got the right value from &baz');
+
+# some error cases
+
+{
+    package Bling;
+    use Moose;
+    
+    sub bling { 'Bling::bling' }
+    
+    package Bling::Bling;
+    use Moose;
+    
+    extends 'Bling';
+    
+    sub bling { 'Bling::bling' }    
+    
+    ::dies_ok {
+        override 'bling' => sub {};
+    } '... cannot override a method which has a local equivalent';
+    
+}
+