From: Shawn M Moore Date: Tue, 10 Jun 2008 04:14:57 +0000 (+0000) Subject: use overload::StrVal in type-constraint errors X-Git-Tag: 0.04~53 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e8b3db47ed7f906cc4ad294d2a28b36656a3c333;p=gitmo%2FMouse.git use overload::StrVal in type-constraint errors --- diff --git a/lib/Mouse/Attribute.pm b/lib/Mouse/Attribute.pm index 7d3c380..a2569d4 100644 --- a/lib/Mouse/Attribute.pm +++ b/lib/Mouse/Attribute.pm @@ -60,7 +60,7 @@ sub generate_accessor { if ($constraint) { $accessor .= 'do { - my $display = defined($_) ? $_ : "undef"; + my $display = defined($_) ? overload::StrVal($_) : "undef"; Carp::confess("Attribute ($name) does not pass the type constraint because: Validation failed for \'$type\' failed with value $display") unless $constraint->(); };' } diff --git a/t/024-isa.t b/t/024-isa.t index ae8a594..670a611 100644 --- a/t/024-isa.t +++ b/t/024-isa.t @@ -84,7 +84,7 @@ for my $type (@types) { } for my $value (@{ $values_for_type{$type}{invalid} }) { - my $display = defined($value) ? $value : 'undef'; + my $display = defined($value) ? overload::StrVal($value) : 'undef'; my $via_new; throws_ok { $via_new = Class->new($type => $value);