use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
use Moose::Meta::TypeConstraint;
use Moose::Util::TypeConstraints;
{
local $TODO = 'type names are not validated in the TC metaclass';
- throws_ok { Moose::Meta::TypeConstraint->new( name => 'Foo-Bar' ) }
- qr/contains invalid characters/,
- 'Type names cannot contain a dash';
+ # Test written in this way to avoid a warning from like(undef, qr...);
+ # -- rjbs, 2010-10-25
+ my $error = exception {
+ Moose::Meta::TypeConstraint->new( name => 'Foo-Bar' )
+ };
+
+ if (defined $error) {
+ like(
+ $error,
+ qr/contains invalid characters/,
+ 'Type names cannot contain a dash',
+ );
+ } else {
+ fail("Type names cannot contain a dash");
+ }
}
-lives_ok { Moose::Meta::TypeConstraint->new( name => 'Foo.Bar::Baz' ) }
-'Type names can contain periods and colons';
+is( exception { Moose::Meta::TypeConstraint->new( name => 'Foo.Bar::Baz' ) }, undef, 'Type names can contain periods and colons' );
-throws_ok { subtype 'Foo-Baz' => as 'Item' }
-qr/contains invalid characters/,
- 'Type names cannot contain a dash (via subtype sugar)';
+like( exception { subtype 'Foo-Baz' => as 'Item' }, qr/contains invalid characters/, 'Type names cannot contain a dash (via subtype sugar)' );
-lives_ok { subtype 'Foo.Bar::Baz' => as 'Item' }
-'Type names can contain periods and colons (via subtype sugar)';
+is( exception { subtype 'Foo.Bar::Baz' => as 'Item' }, undef, 'Type names can contain periods and colons (via subtype sugar)' );
is( Moose::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[In-valid]'),
undef,