File: 015-compose-keywords.t

package info (click to toggle)
libmoosex-role-parameterized-perl 1.11-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 464 kB
  • sloc: perl: 439; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,122 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;
use Test::More 0.88;

do {
    package OtherRole;
    use Moose::Role;
};

do {
    package MyRole;
    use MooseX::Role::Parameterized;

    requires 'requirement';
    excludes 'exclusion';

    has attribute => ();

    method meth => sub {};
    before meth => sub {};
    after  meth => sub {};
    around meth => sub {};

    sub regular_method {}

    override other_meth => sub { super };

    with 'OtherRole';

    role { }
};

for my $meta (MyRole->meta, MyRole->meta->generate_role) {
    ok($meta->has_attribute('attribute'), 'has');
    ok($meta->has_method('meth'), 'method');
    ok($meta->has_method('regular_method'), 'sub');

    is($meta->has_before_method_modifiers('meth'), 1, 'before');
    is($meta->has_after_method_modifiers('meth'),  1, 'after');
    is($meta->has_around_method_modifiers('meth'), 1, 'around');

    is($meta->has_override_method_modifier('other_meth'), 1, 'override');
    is($meta->does_role('OtherRole'), 1, 'with');

    ok($meta->requires_method('requirement'), 'requires');
    ok($meta->excludes_role('exclusion'), 'excludes');
}

done_testing;