TypeConstraint::Utils,.. now with find_or_create_type_constraint goodness
[gitmo/Moose.git] / t / 040_type_constraints / 002_util_type_constraints_export.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 5;
7 use Test::Exception;
8
9 BEGIN {
10         use_ok('Moose::Util::TypeConstraints', { into => 'Foo' } );
11 }
12
13 {
14     package Foo;
15
16         eval {
17                 type MyRef => where { ref($_) };
18         };
19         ::ok(!$@, '... successfully exported &type to Foo package');
20         
21         eval {
22                 subtype MyArrayRef 
23                         => as MyRef 
24                         => where { ref($_) eq 'ARRAY' };
25         };
26         ::ok(!$@, '... successfully exported &subtype to Foo package'); 
27         
28     Moose::Util::TypeConstraints->export_type_constraints_as_functions();       
29         
30         ::ok(MyRef({}), '... Ref worked correctly');
31         ::ok(MyArrayRef([]), '... ArrayRef worked correctly');  
32 }