Revert most of the conversion to Test::Fatal so we can redo it
[gitmo/Moose.git] / t / 020_attributes / 013_attr_dereference_test.t
index bc11931..fa78897 100644 (file)
@@ -3,12 +3,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More;
 use Test::Exception;
 
-BEGIN {
-    use_ok('Moose');
-}
 
 {
     package Customer;
@@ -21,7 +18,7 @@ BEGIN {
     ::lives_ok {
         has 'customers' => (
             is         => 'ro',
-            isa        => subtype('ArrayRef' => where { 
+            isa        => subtype('ArrayRef' => where {
                             (blessed($_) && $_->isa('Customer') || return) for @$_; 1 }),
             auto_deref => 1,
         );
@@ -55,4 +52,31 @@ BEGIN {
         [],
         '... got the right dereferenced value'
     );
-}
\ No newline at end of file
+}
+
+{
+    package AutoDeref;
+    use Moose;
+
+    has 'bar' => (
+        is         => 'rw',
+        isa        => 'ArrayRef[Int]',
+        auto_deref => 1,
+    );
+}
+
+{
+    my $autoderef = AutoDeref->new;
+
+    dies_ok {
+        $autoderef->bar(1, 2, 3);
+    } '... its auto-de-ref-ing, not auto-en-ref-ing';
+
+    lives_ok  {
+        $autoderef->bar([ 1, 2, 3 ])
+    } '... set the results of bar correctly';
+
+    is_deeply [ $autoderef->bar ], [ 1, 2, 3 ], '... auto-dereffed correctly';
+}
+
+done_testing;