convert all uses of Test::Exception to Test::Fatal.
[gitmo/Moose.git] / t / 010_basics / 010_method_modifier_with_regexp.t
index d52f7f7..404e20b 100644 (file)
@@ -3,11 +3,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 10;
+use Test::More;
+use Test::Fatal;
 
-BEGIN {
-    use_ok('Moose');
-}
 
 {
 
@@ -24,14 +22,14 @@ BEGIN {
     }
 
     around qr/bark.*/ => sub {
-        'Dog::around';
+        'Dog::around(' . $_[0]->() . ')';
     };
 
 }
 
 my $dog = Dog->new;
-is( $dog->bark_once,  'Dog::around', 'around modifier is called' );
-is( $dog->bark_twice, 'Dog::around', 'around modifier is called' );
+is( $dog->bark_once,  'Dog::around(bark)', 'around modifier is called' );
+is( $dog->bark_twice, 'Dog::around(barkbark)', 'around modifier is called' );
 
 {
 
@@ -68,80 +66,21 @@ is( $Cat::BEFORE_BARK_COUNTER, 2, 'before modifier is called twice' );
 is( $Cat::AFTER_BARK_COUNTER,  2, 'after modifier is called twice' );
 
 {
+    package Dog::Role;
+    use Moose::Role;
 
-    package Animal;
-    use Moose;
-    our $BEFORE_BARK_COUNTER = 0;
-    our $AFTER_BARK_COUNTER  = 0;
-
-    sub bark_once {
-        my $self = shift;
-        return 'bark';
-    }
-
-    sub bark_twice {
-        return 'barkbark';
-    }
-
-    before qr/bark.*/ => sub {
-        $BEFORE_BARK_COUNTER++;
-    };
-
-    after qr/bark.*/ => sub {
-        $AFTER_BARK_COUNTER++;
-    };
-}
-
-{
-
-    package Cow;
-    use Moose;
-    extends 'Animal';
-
-    override 'bark_once' => sub {
-        my $self = shift;
-        super();
-        return 'cow';
-    };
-
-    override 'bark_twice' => sub {
-        super();        
-        return 'cowcow';
-    };
-}
-
-{
-    my $cow = Cow->new;
-    $cow->bark_once;
-    is( $Animal::BEFORE_BARK_COUNTER, 1,
-        'before modifier is called if method is overridden' );
-    is( $Animal::AFTER_BARK_COUNTER, 1,
-        'after modifier is called if method is overridden' );
-}
-
-{
+    ::ok ::exception {
+        before qr/bark.*/ => sub {};
+    }, '... this is not currently supported';
 
-    package MyDog;
-    use Moose;
-    our $BEFORE_BARK_COUNTER=0;
-    sub bark {
-        my $self = shift;
-        return 'bark';
-    }
-    
-    sub bark_twice {
-        my $self = shift;
-        return 'barkbark';
-    }
+    ::ok ::exception {
+        around qr/bark.*/ => sub {};
+    }, '... this is not currently supported';
 
-    before qw/bark bark_twice/ => sub {
-        $BEFORE_BARK_COUNTER++;
-    };
+    ::ok ::exception {
+        after  qr/bark.*/ => sub {};
+    }, '... this is not currently supported';
 
 }
 
-my $my_dog = MyDog->new;
-$my_dog->bark;
-$my_dog->bark_twice;
-is($MyDog::BEFORE_BARK_COUNTER, 2, "before method modifier is called twice");
-
+done_testing;