File: 102-nested.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 (52 lines) | stat: -rw-r--r-- 1,298 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
50
51
52
use strict;
use warnings;
use Test::More 0.88;
use Test::Fatal;

use lib 't/lib';

{
    package Foo;
    use MooseX::Role::Parameterized;

    parameter 'outer' => (
        default => 'yep..',
    );

    role {
        with 'Bar', { include_is_bar => 0 };

        method is_foo => sub { 1 };
    };
}

{
    package Foo::Class;
    use Moose;
    ::is( ::exception {
        with 'Foo';
    }, undef, 'Can consume the Foo role without providing parameters');
}

{
    package Bar::Class;
    use Moose;
    ::is( ::exception {
        with 'Bar';
    }, undef, 'Can consume the Bar role without providing parameters');
}

my $foo = Foo::Class->meta->roles->[0];
ok($foo->has_method('is_foo'), 'Foo got the "is_foo" method');
ok(!$foo->has_method('is_bar'), 'Foo did not get the "is_bar" method from Bar');

my $bar = Bar::Class->meta->roles->[0];
ok($bar->has_method('is_bar'), 'Bar got the "is_bar" method');
ok(!$bar->has_method('is_foo'), 'Bar does not get "is_foo"');

ok(Foo->meta->has_parameter('outer'), 'Foo has outer param');
ok(Bar->meta->has_parameter('include_is_bar'), 'Bar has include_is_bar param');
ok(!Foo->meta->has_parameter('include_is_bar'), 'Foo does not have include_is_bar param');
ok(!Bar->meta->has_parameter('outer'), 'Bar does not have outer param');

done_testing;