6 use Test::More tests => 6;
10 use_ok('Moose::Util::TypeConstraints');
19 has 'array' => (is => 'ro');
20 has 'hash' => (is => 'ro');
25 => where { $_->isa('HTTPHeader') };
29 => to { HTTPHeader->new(array => $_[0]) }
31 => to { HTTPHeader->new(hash => $_[0]) };
33 Moose::Util::TypeConstraints::export_type_contstraints_as_functions();
35 my $header = HTTPHeader->new();
36 isa_ok($header, 'HTTPHeader');
38 ok(Header($header), '... this passed the type test');
39 ok(!Header([]), '... this did not pass the type test');
40 ok(!Header({}), '... this did not pass the type test');
42 my $coercion = Moose::Util::TypeConstraints::find_type_coercion('Header');
43 is(ref($coercion), 'CODE', '... got the right type of coercion');
46 # my $coerced = $coercion->([ 1, 2, 3 ]);
47 # isa_ok($coerced, 'HTTPHeader');
52 # '... got the right array');
53 # is($coerced->hash(), undef, '... nothing assigned to the hash');
57 # my $coerced = $coercion->({ one => 1, two => 2, three => 3 });
58 # isa_ok($coerced, 'HTTPHeader');
62 # { one => 1, two => 2, three => 3 },
63 # '... got the right hash');
64 # is($coerced->array(), undef, '... nothing assigned to the array');