* role exclusion and aliasiing now works in composite roles too
[gitmo/Moose.git] / t / 040_type_constraints / 020_class_type_constraint.t
CommitLineData
3fef8ce8 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
28412c0b 6use Test::More tests => 7;
3fef8ce8 7
8BEGIN {
9 use_ok('Moose::Util::TypeConstraints');
10}
11
12{
13 package Gorch;
14 use Moose;
15
16 package Bar;
17 use Moose;
18
19 package Foo;
20 use Moose;
21
22 extends qw(Bar Gorch);
23}
24
25my $type = find_type_constraint("Foo");
26
27ok( $type->is_subtype_of("Gorch"), "subtype of gorch" );
28
29ok( $type->is_subtype_of("Bar"), "subtype of bar" );
30
31ok( $type->is_subtype_of("Object"), "subtype of Object" );
32
33ok( find_type_constraint("Bar")->check(Foo->new), "Foo passes Bar" );
34ok( find_type_constraint("Bar")->check(Bar->new), "Bar passes Bar" );
35ok( !find_type_constraint("Gorch")->check(Bar->new), "but Bar doesn't pass Gorch");
36