Throw a more useful error when users try to use a parameterized type,
Shawn M Moore [Mon, 23 Feb 2009 02:46:41 +0000 (02:46 +0000)]
with a meager todo test

lib/Mouse/Meta/Attribute.pm
t/043-parameterized-type.t [new file with mode: 0644]

index 9683342..4387bcd 100644 (file)
@@ -204,6 +204,9 @@ sub create {
         if exists $args{coerce};
 
     if (exists $args{isa}) {
+        confess "Mouse does not yet support parameterized types (rt.cpan.org #39795)"
+            if $args{isa} =~ /\[.*\]/;
+
         my $type_constraint = delete $args{isa};
         $type_constraint =~ s/\s//g;
         my @type_constraints = split /\|/, $type_constraint;
diff --git a/t/043-parameterized-type.t b/t/043-parameterized-type.t
new file mode 100644 (file)
index 0000000..8bc1d98
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 1;
+use Test::Exception;
+
+TODO: {
+    local $TODO = "Mouse does not support parameterized types yet";
+
+    eval {
+        package Foo;
+        use Mouse;
+
+        has foo => (
+            is  => 'ro',
+            isa => 'HashRef[Int]',
+        );
+    };
+
+    ok(Foo->meta->has_attribute('foo'));
+};
+