~ubuntu-branches/ubuntu/raring/libmoosex-methodattributes-perl/raring

« back to all changes in this revision

Viewing changes to t/multiple_roles_astrait.t

  • Committer: Bazaar Package Importer
  • Author(s): Ansgar Burchardt
  • Date: 2010-06-01 21:38:04 UTC
  • mfrom: (1.1.11 upstream) (5.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100601213804-v0rycpl4eh3qe7wb
Tags: 0.22-1
* New upstream release.
* Bump (build-)dep on libmoose-perl to >= 0.98.
* Bump (build-)dep on libmoosex-types-perl to >= 0.20.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
use strict;
2
 
use warnings;
3
 
use MooseX::MethodAttributes ();
4
 
 
5
 
use Test::More tests => 2;
6
 
 
7
 
# This tests the 'old' form of using MooseX::MethodAttributes with -traits => 'MethodAttributes'
8
 
# The new (and nicer) way is to just say use MooseX::MethodAttributes::Role
9
 
 
10
 
{
11
 
    package Bar;
12
 
    use Moose::Role -traits => 'MethodAttributes';
13
 
    use namespace::clean -except => 'meta';
14
 
 
15
 
    sub item :Chained(/app/root) PathPrefix CaptureArgs(1) { }
16
 
}
17
 
 
18
 
{
19
 
    package Foo;
20
 
    use Moose::Role -traits => 'MethodAttributes';
21
 
    use namespace::clean -except => 'meta';
22
 
 
23
 
    sub live :Chained(item) PathPart Args(0) { }
24
 
    sub foo :Attr { }
25
 
    sub other :Attr { }
26
 
}
27
 
 
28
 
{
29
 
    package Catalyst::Controller;
30
 
    use Moose;
31
 
    use namespace::clean -except => 'meta';
32
 
 
33
 
    BEGIN { extends qw/MooseX::MethodAttributes::Inheritable/; }
34
 
}
35
 
 
36
 
use Moose::Util;
37
 
use Moose::Meta::Class;;
38
 
 
39
 
Moose::Meta::Class->create("MyClass",
40
 
    superclasses => [qw/Catalyst::Controller/],
41
 
    roles => ["Bar", "Foo"],
42
 
);
43
 
 
44
 
 
45
 
ok MyClass->meta->can('get_all_methods_with_attributes')
46
 
    or skip 'Role combination and method attributes known broken', 1;
47
 
 
48
 
my @methods;
49
 
for my $method (sort { $a->name cmp $b->name } MyClass->meta->get_all_methods_with_attributes) {
50
 
    push(@methods, $method->name . " :" . join("|", @{ $method->attributes }));
51
 
}
52
 
 
53
 
is_deeply \@methods, [
54
 
    'foo :Attr',
55
 
    'item :Chained(/app/root)|PathPrefix|CaptureArgs(1)',
56
 
    'live :Chained(item)|PathPart|Args(0)',
57
 
    'other :Attr',
58
 
], 'methods with expected attributes found';
59
 
 
 
1
use strict;
 
2
use warnings;
 
3
use MooseX::MethodAttributes ();
 
4
 
 
5
use Test::More tests => 2;
 
6
 
 
7
# This tests the 'old' form of using MooseX::MethodAttributes with -traits => 'MethodAttributes'
 
8
# The new (and nicer) way is to just say use MooseX::MethodAttributes::Role
 
9
 
 
10
{
 
11
    package Bar;
 
12
    use Moose::Role -traits => 'MethodAttributes';
 
13
    use namespace::clean -except => 'meta';
 
14
 
 
15
    sub item :Chained(/app/root) PathPrefix CaptureArgs(1) { }
 
16
}
 
17
 
 
18
{
 
19
    package Foo;
 
20
    use Moose::Role -traits => 'MethodAttributes';
 
21
    use namespace::clean -except => 'meta';
 
22
 
 
23
    sub live :Chained(item) PathPart Args(0) { }
 
24
    sub foo :Attr { }
 
25
    sub other :Attr { }
 
26
}
 
27
 
 
28
{
 
29
    package Catalyst::Controller;
 
30
    use Moose;
 
31
    use namespace::clean -except => 'meta';
 
32
 
 
33
    BEGIN { extends qw/MooseX::MethodAttributes::Inheritable/; }
 
34
}
 
35
 
 
36
use Moose::Util;
 
37
use Moose::Meta::Class;;
 
38
 
 
39
Moose::Meta::Class->create("MyClass",
 
40
    superclasses => [qw/Catalyst::Controller/],
 
41
    roles => ["Bar", "Foo"],
 
42
);
 
43
 
 
44
 
 
45
ok MyClass->meta->can('get_all_methods_with_attributes')
 
46
    or skip 'Role combination and method attributes known broken', 1;
 
47
 
 
48
my @methods;
 
49
for my $method (sort { $a->name cmp $b->name } MyClass->meta->get_all_methods_with_attributes) {
 
50
    push(@methods, $method->name . " :" . join("|", @{ $method->attributes }));
 
51
}
 
52
 
 
53
is_deeply \@methods, [
 
54
    'foo :Attr',
 
55
    'item :Chained(/app/root)|PathPrefix|CaptureArgs(1)',
 
56
    'live :Chained(item)|PathPart|Args(0)',
 
57
    'other :Attr',
 
58
], 'methods with expected attributes found';
 
59