File: role_in_role_more.t

package info (click to toggle)
libmoosex-methodattributes-perl 0.32-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 496 kB
  • sloc: perl: 648; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,234 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use strict;
use warnings;
use MooseX::MethodAttributes ();

{
    package Bar;
    use Moose::Role -traits => 'MethodAttributes';
    use namespace::autoclean;

    sub item :Chained(/app/root) PathPrefix CaptureArgs(1) { }
}

{
    package Foo;
    use Moose::Role -traits => 'MethodAttributes';
    use namespace::autoclean;

    with 'Bar';

    sub live :Chained(item) PathPart Args(0) { }
    sub foo :Attr { }
    sub other :Attr { }
}

{
    package Catalyst::Controller;
    use Moose;
    use namespace::autoclean;

    with 'MooseX::MethodAttributes::Role::AttrContainer::Inheritable';
}

use Test::More tests => 1;
use Moose::Util;
use Moose::Meta::Class;;

my @roles = qw/Foo/;

Moose::Meta::Class->create("MyClass",
    superclasses => [qw/Catalyst::Controller/],
    roles => \@roles,
);

my @methods;
for my $method (sort { $a->name cmp $b->name } MyClass->meta->get_all_methods_with_attributes) {
    push(@methods, $method->name . " :" . join("|", @{ $method->attributes }));
}

is_deeply \@methods, [
    'foo :Attr',
    'item :Chained(/app/root)|PathPrefix|CaptureArgs(1)',
    'live :Chained(item)|PathPart|Args(0)',
    'other :Attr',
], 'methods with expected attributes found'
    or diag explain(\@methods);