Fix tests
[gitmo/Mouse.git] / t / 100_bugs / 028_apply_role_to_one_instance_only.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 use strict;
6 use warnings;
7 use Test::More;
8 $TODO = q{Mouse is not yet completed};
9 use Test::Exception;
10
11 {
12     package MyRole1;
13     use Mouse::Role;
14
15     sub a_role_method { 'foo' }
16 }
17
18 {
19     package MyRole2;
20     use Mouse::Role;
21     # empty
22 }
23
24 {
25     package Foo;
26     use Mouse;
27 }
28
29 my $instance_with_role1 = Foo->new;
30 MyRole1->meta->apply($instance_with_role1);
31
32 my $instance_with_role2 = Foo->new;
33 MyRole2->meta->apply($instance_with_role2);
34
35 ok ((not $instance_with_role2->does('MyRole1')),
36     'instance does not have the wrong role');
37
38 ok ((not $instance_with_role2->can('a_role_method')),
39     'instance does not have methods from the wrong role');
40
41 ok (($instance_with_role1->does('MyRole1')),
42     'role was applied to the correct instance');
43
44 lives_and {
45     is $instance_with_role1->a_role_method, 'foo'
46 } 'instance has correct role method';
47
48 done_testing;