Add support for :all on MooseX::Types::Combine
[gitmo/MooseX-Types.git] / t / 18_combined_libs.t
CommitLineData
ca9d7442 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use FindBin;
587387ef 5use lib "$FindBin::Bin/lib";
bd47cf64 6
a344ca96 7use Test::More;
10390913 8use Test::Fatal;
ca9d7442 9
10BEGIN { use_ok 'Combined', qw/Foo2Alias MTFNPY NonEmptyStr/ }
11
12# test that a type from TestLibrary was exported
13ok Foo2Alias;
14
15# test that a type from TestLibrary2 was exported
16ok MTFNPY;
17
18is NonEmptyStr->name, 'TestLibrary2::NonEmptyStr',
19 'precedence for conflicting types is correct';
bd47cf64 20
10390913 21like exception { Combined->import('NonExistentType') },
bd47cf64 22qr/\Qmain asked for a type (NonExistentType) which is not found in any of the type libraries (TestLibrary TestLibrary2) combined by Combined/,
23'asking for a non-existent type from a combined type library gives a useful error';
587387ef 24
25{
26 package BadCombined;
27
28 use base 'MooseX::Types::Combine';
29
30 ::like ::exception { __PACKAGE__->provide_types_from('Empty') },
31 qr/Cannot use Empty in a combined type library, it does not provide any types/,
32 'cannot combine types from a package which is not a type library';
33
34 ::like ::exception { __PACKAGE__->provide_types_from('DoesNotExist') },
35 qr/Can't locate DoesNotExist\.pm/,
36 'cannot combine types from a package which does not exist';
37}
a344ca96 38
be4acfcc 39is exception { 'Combined'->import(':all') }, undef, ':all syntax works';
40
a344ca96 41done_testing();