Resolve RT #61852, thanks to Vincent Pit
[gitmo/Mouse.git] / t / 900_mouse_bugs / 011_RT61852.t
diff --git a/t/900_mouse_bugs/011_RT61852.t b/t/900_mouse_bugs/011_RT61852.t
new file mode 100644 (file)
index 0000000..1ce0abe
--- /dev/null
@@ -0,0 +1,31 @@
+#!perl
+# https://rt.cpan.org/Public/Bug/Display.html?id=61852
+use strict;
+use warnings;
+use Test::More;
+{
+ package X;
+ use Mouse;
+ use Mouse::Util::TypeConstraints;
+
+ subtype 'List'
+      => as 'ArrayRef[Any]'
+      => where {
+       foreach my $item(@{$_}) {
+        defined($item) or return 0;
+       }
+       return 1;
+      };
+
+ has 'list' => (
+  is  => 'ro',
+  isa => 'List',
+ );
+}
+
+eval { X->new(list => [ 1, 2, 3 ]) };
+is $@, '';
+
+eval { X->new(list => [ 1, undef, 3 ]) };
+like $@, qr/Validation[ ]failed[ ]for[ ]'List'/xms;
+done_testing;