[Moose-commits] r7782 - in Mouse/trunk: lib/Mouse/Meta t
sartak at code2.0beta.co.uk
sartak at code2.0beta.co.uk
Mon Feb 23 02:46:41 GMT 2009
Author: sartak
Date: 2009-02-22 18:46:41 -0800 (Sun, 22 Feb 2009)
New Revision: 7782
Added:
Mouse/trunk/t/043-parameterized-type.t
Modified:
Mouse/trunk/lib/Mouse/Meta/Attribute.pm
Log:
Throw a more useful error when users try to use a parameterized type,
with a meager todo test
Modified: Mouse/trunk/lib/Mouse/Meta/Attribute.pm
===================================================================
--- Mouse/trunk/lib/Mouse/Meta/Attribute.pm 2009-02-22 19:48:29 UTC (rev 7781)
+++ Mouse/trunk/lib/Mouse/Meta/Attribute.pm 2009-02-23 02:46:41 UTC (rev 7782)
@@ -204,6 +204,9 @@
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;
Added: Mouse/trunk/t/043-parameterized-type.t
===================================================================
--- Mouse/trunk/t/043-parameterized-type.t (rev 0)
+++ Mouse/trunk/t/043-parameterized-type.t 2009-02-23 02:46:41 UTC (rev 7782)
@@ -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'));
+};
+
More information about the Moose-commits
mailing list