bump version to 0.25
[gitmo/MooseX-Types.git] / t / 18_combined_libs.t
index a7e2529..6ef2191 100644 (file)
@@ -2,10 +2,10 @@
 use strict;
 use warnings;
 use FindBin;
-use lib "$FindBin::Bin/lib";   
+use lib "$FindBin::Bin/lib";
 
-use Test::More tests => 5;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
 
 BEGIN { use_ok 'Combined', qw/Foo2Alias MTFNPY NonEmptyStr/ }
 
@@ -18,6 +18,22 @@ ok MTFNPY;
 is NonEmptyStr->name, 'TestLibrary2::NonEmptyStr',
     'precedence for conflicting types is correct';
 
-throws_ok { Combined->import('NonExistentType') }
+like exception { Combined->import('NonExistentType') },
 qr/\Qmain asked for a type (NonExistentType) which is not found in any of the type libraries (TestLibrary TestLibrary2) combined by Combined/,
 'asking for a non-existent type from a combined type library gives a useful error';
+
+{
+    package BadCombined;
+
+    use base 'MooseX::Types::Combine';
+
+    ::like ::exception { __PACKAGE__->provide_types_from('Empty') },
+    qr/Cannot use Empty in a combined type library, it does not provide any types/,
+    'cannot combine types from a package which is not a type library';
+
+    ::like ::exception { __PACKAGE__->provide_types_from('DoesNotExist') },
+    qr/Can't locate DoesNotExist\.pm/,
+    'cannot combine types from a package which does not exist';
+}
+
+done_testing();