Require Dist::Zilla 4.200016+
[gitmo/Moose.git] / t / type_constraints / subtype_auto_vivify_parent.t
CommitLineData
4c252d25 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
a28e50e4 6use Test::More;
4c252d25 7
8use Moose::Util::TypeConstraints;
9
10
11{
12 package Foo;
13
14 sub new {
15 my $class = shift;
16
17 return bless {@_}, $class;
18 }
19}
20
21subtype 'FooWithSize'
22 => as 'Foo'
23 => where { $_[0]->{size} };
24
25
26my $type = find_type_constraint('FooWithSize');
27ok( $type, 'made a FooWithSize constraint' );
28ok( $type->parent, 'type has a parent type' );
29is( $type->parent->name, 'Foo', 'parent type is Foo' );
30isa_ok( $type->parent, 'Moose::Meta::TypeConstraint::Class',
31 'parent type constraint is a class type' );
a28e50e4 32
33done_testing;