foo
[gitmo/Moose.git] / t / 071_misc_attribute_tests.t
index 808e646..79391d1 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 12;
 use Test::Exception;
 
 BEGIN {
@@ -104,3 +104,25 @@ BEGIN {
     
 }
 
+{
+    {
+        package OverloadedStr;
+        use Moose;
+        use overload '""' => sub { 'this is *not* a string' };
+
+        has 'a_str' => ( isa => 'Str' , is => 'rw' );
+    }
+
+    my $moose_obj = OverloadedStr->new;
+
+    is($moose_obj->a_str( 'foobar' ), 'foobar', 'setter took string');
+    ok($moose_obj, 'this is a *not* a string');
+
+    throws_ok { 
+        $moose_obj->a_str( $moose_obj ) 
+    } qr/Attribute \(a_str\) does not pass the type constraint \(Str\) with OverloadedStr\=HASH\(.*?\)/, '... dies without overloading the string';
+
+}
+
+
+