Cleanup failing tests
[gitmo/Mouse.git] / Moose-t-failing / 020_attributes / 005_attribute_does.t
1 #!/usr/bin/perl
2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
5
6 use strict;
7 use warnings;
8
9 use Test::More;
10 $TODO = q{Mouse is not yet completed};
11 use Test::Exception;
12
13
14 {
15     package Foo::Role;
16     use Mouse::Role;
17     use Mouse::Util::TypeConstraints;
18
19     # if does() exists on its own, then
20     # we create a type constraint for
21     # it, just as we do for isa()
22     has 'bar' => (is => 'rw', does => 'Bar::Role');
23     has 'baz' => (
24         is   => 'rw',
25         does => role_type('Bar::Role')
26     );
27
28     package Foo::Class;
29     use Mouse;
30
31     with 'Foo::Role';
32
33     package Bar::Role;
34     use Mouse::Role;
35
36     # if isa and does appear together, then see if Class->does(Role)
37     # if it does work... then the does() check is actually not needed
38     # since the isa() check will imply the does() check
39     has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role');
40
41     package Bar::Class;
42     use Mouse;
43
44     with 'Bar::Role';
45 }
46
47 my $foo = Foo::Class->new;
48 isa_ok($foo, 'Foo::Class');
49
50 my $bar = Bar::Class->new;
51 isa_ok($bar, 'Bar::Class');
52
53 lives_ok {
54     $foo->bar($bar);
55 } '... bar passed the type constraint okay';
56
57 dies_ok {
58     $foo->bar($foo);
59 } '... foo did not pass the type constraint okay';
60
61 lives_ok {
62     $foo->baz($bar);
63 } '... baz passed the type constraint okay';
64
65 dies_ok {
66     $foo->baz($foo);
67 } '... foo did not pass the type constraint okay';
68
69 lives_ok {
70     $bar->foo($foo);
71 } '... foo passed the type constraint okay';
72
73
74
75 # some error conditions
76
77 {
78     package Baz::Class;
79     use Mouse;
80
81     # if isa and does appear together, then see if Class->does(Role)
82     # if it does not,.. we have a conflict... so we die loudly
83     ::dies_ok {
84         has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class');
85     } '... cannot have a does() which is not done by the isa()';
86 }
87
88 {
89     package Bling;
90     use strict;
91     use warnings;
92
93     sub bling { 'Bling::bling' }
94
95     package Bling::Bling;
96     use Mouse;
97
98     # if isa and does appear together, then see if Class->does(Role)
99     # if it does not,.. we have a conflict... so we die loudly
100     ::dies_ok {
101         has 'foo' => (isa => 'Bling', does => 'Bar::Class');
102     } '... cannot have a isa() which is cannot does()';
103 }
104
105 done_testing;