Changelogging
[gitmo/Mouse.git] / t-failing / 400_moose_util / 005_ensure_all_roles.t
CommitLineData
fde8e43f 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!!!
4use t::lib::MooseCompat;
5
6use strict;
7use warnings;
8
9use Test::More;
10$TODO = q{Mouse is not yet completed};
11
12BEGIN {
13 use_ok('Mouse::Util', ':all');
14}
15
16{
17 package Foo;
18 use Mouse::Role;
19}
20
21{
22 package Bar;
23 use Mouse::Role;
24}
25
26{
27 package Quux;
28 use Mouse;
29}
30
31is_deeply(
32 Quux->meta->roles,
33 [],
34 "no roles yet",
35);
36
37Foo->meta->apply(Quux->meta);
38
39is_deeply(
40 Quux->meta->roles,
41 [ Foo->meta ],
42 "applied Foo",
43);
44
45Foo->meta->apply(Quux->meta);
46Bar->meta->apply(Quux->meta);
47is_deeply(
48 Quux->meta->roles,
49 [ Foo->meta, Foo->meta, Bar->meta ],
50 "duplicated Foo",
51);
52
53is(does_role('Quux', 'Foo'), 1, "Quux does Foo");
54is(does_role('Quux', 'Bar'), 1, "Quux does Bar");
55ensure_all_roles('Quux', qw(Foo Bar));
56is_deeply(
57 Quux->meta->roles,
58 [ Foo->meta, Foo->meta, Bar->meta ],
59 "unchanged, since all roles are already applied",
60);
61
62my $obj = Quux->new;
63ensure_all_roles($obj, qw(Foo Bar));
64is_deeply(
65 $obj->meta->roles,
66 [ Foo->meta, Foo->meta, Bar->meta ],
67 "unchanged, since all roles are already applied",
68);
69
70done_testing;