Revision history for MooseX-Types
+0.14 Fri Jun 26 17:52:20 PDT 2009
+ - Fix union with string type
+
0.13 Tue Jun 23 05:46:33 PDT 2009
- Add Test::Moose to build_requires for Fedora
use namespace::clean -except => [qw( meta )];
use 5.008;
-our $VERSION = '0.13';
+our $VERSION = '0.14';
my $UndefMsg = q{Action for type '%s' not yet defined in library '%s'};
=head1 SYNOPSIS
## It's kind of ugly that we need to know about Union Types, but this
## is needed for syntax compatibility. Maybe someday we'll all just do
## Or[Str,Str,Int]
-
- my @tc = grep {blessed $_} @_;
+
+ my @tc = map {
+ blessed $_ ? $_ :
+ Moose::Util::TypeConstraints::find_or_parse_type_constraint($_)
+ } @_;
+
my $union = Moose::Meta::TypeConstraint::Union->new(type_constraints=>\@tc);
return Moose::Util::TypeConstraints::register_type_constraint($union);
},
--- /dev/null
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+my $exception;
+{
+ package TypeLib;
+
+ use MooseX::Types -declare => [qw( MyUnionType MyStr )];
+ use MooseX::Types::Moose qw(Str Item);
+
+ subtype MyUnionType, as Str|'Int';
+ subtype MyStr, as Str;
+
+ eval { coerce MyStr, from Item, via {"$_"} };
+ $exception = $@;
+}
+
+ok !$@, 'types are not mutated by union with a string type';