use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More;
use Test::Exception;
-BEGIN {
- use_ok('Moose');
-}
{
package Customer;
::lives_ok {
has 'customers' => (
is => 'ro',
- isa => subtype('ArrayRef' => where {
+ isa => subtype('ArrayRef' => where {
(blessed($_) && $_->isa('Customer') || return) for @$_; 1 }),
auto_deref => 1,
);
[],
'... 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;