From: Shawn M Moore Date: Fri, 28 Dec 2007 22:49:17 +0000 (+0000) Subject: Add failing! tests to ArrayRef[Int] + auto_deref X-Git-Tag: 0_35~48 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=547181699327dddb793b9a964a5f3b92b14fa43f;p=gitmo%2FMoose.git Add failing! tests to ArrayRef[Int] + auto_deref --- diff --git a/t/040_type_constraints/011_container_type_constraint.t b/t/040_type_constraints/011_container_type_constraint.t index 32b3430..829d96f 100644 --- a/t/040_type_constraints/011_container_type_constraint.t +++ b/t/040_type_constraints/011_container_type_constraint.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 22; +use Test::More tests => 25; use Test::Exception; BEGIN { @@ -64,3 +64,21 @@ ok(!$array_of_array_of_ints->check( [[ 1, 2, 3 ], [ qw/foo bar/ ]] ), '... [[ 1, 2, 3 ], [ qw/foo bar/ ]] failed successfully'); +{ + package AutoDeref; + use Moose; + use Moose::Util::TypeConstraints; + + has 'bar' => ( + is => 'rw', + isa => 'ArrayRef[Int]', + auto_deref => 1, + ); +} + +my $autoderef = AutoDeref->new; +lives_ok { $autoderef->bar(1, 2, 3) }; +is_deeply [ $autoderef->bar ], [1, 2, 3]; + +dies_ok { $autoderef->bar(1, "foo", 3) }; +