more tying to convert my methods to real objects
[gitmo/MooseX-Types-Structured.git] / t / 01-basic.t
CommitLineData
bfef1b30 1BEGIN {
2 use strict;
3 use warnings;
4 use Test::More tests=>4;
5 use Test::Exception;
6
7 use_ok 'Moose::Util::TypeConstraints';
8 use_ok 'MooseX::Meta::TypeConstraint::Structured::Positionable';
9}
10
11ok my $REGISTRY = Moose::Meta::TypeConstraint::Registry->new
12 => 'Got a registry';
13
14my $tuple = MooseX::Meta::TypeConstraint::Structured::Positionable->new(
15 name => 'Tuple',
16 package_defined_in => __PACKAGE__,
17 parent => find_type_constraint('Ref'),
18 );
19
20
21type('Tuple', $tuple);
22
23
24
25
26use Data::Dump qw/dump/;
27#warn dump sort {$a cmp $b} Moose::Util::TypeConstraints::list_all_type_constraints;
28
29
30{
31 package Test::MooseX::Types::Structured::Positionable;
32 use Moose;
33
34 has 'attr' => (is=>'rw', isa=>'Tuple[Int,Str,Int]');
35
36}
37
38ok my $positioned_obj = Test::MooseX::Types::Structured::Positionable->new,
39 => 'Got a good object';
40
41## should be good
42$positioned_obj->attr([1,'hello',3]);
43
44## should all fail
45$positioned_obj->attr([1,2,'world']);
46$positioned_obj->attr(['hello',2,3]);
47$positioned_obj->attr(['hello',2,'world']);