Remove our (now broken) dzil GatherDir subclass
[gitmo/Moose.git] / t / moose_util / with_traits.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More;
5 use Test::Moose;
6
7 use Moose ();
8 use Moose::Util qw(with_traits);
9
10 {
11     package Foo;
12     use Moose;
13 }
14
15 {
16     package Foo::Role;
17     use Moose::Role;
18 }
19
20 {
21     package Foo::Role2;
22     use Moose::Role;
23 }
24
25 {
26     my $traited_class = with_traits('Foo', 'Foo::Role');
27     ok($traited_class->meta->is_anon_class, "we get an anon class");
28     isa_ok($traited_class, 'Foo');
29     does_ok($traited_class, 'Foo::Role');
30 }
31
32 {
33     my $traited_class = with_traits('Foo', 'Foo::Role', 'Foo::Role2');
34     ok($traited_class->meta->is_anon_class, "we get an anon class");
35     isa_ok($traited_class, 'Foo');
36     does_ok($traited_class, 'Foo::Role');
37     does_ok($traited_class, 'Foo::Role2');
38 }
39
40 {
41     my $traited_class = with_traits('Foo');
42     is($traited_class, 'Foo', "don't apply anything if we don't get any traits");
43 }
44
45 {
46     my $traited_class = with_traits('Foo', 'Foo::Role');
47     my $traited_class2 = with_traits('Foo', 'Foo::Role');
48     is($traited_class, $traited_class2, "get the same class back when passing the same roles");
49 }
50
51 done_testing;