File: 023-metarole-import-params.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 (77 lines) | stat: -rw-r--r-- 1,491 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use strict;
use warnings;
use Test::More skip_all => "Not implemented yet";

BEGIN {
    package MyTrait::Label;
    use MooseX::Role::Parameterized;

    parameter default => (
        is  => 'rw',
        isa => 'Str',
    );

    role {
        my $p = shift;

        has label => (
            is      => 'rw',
            isa     => 'Str',
            default => $p->default,
        );
    };
};

BEGIN {
    package MyApp::MooseX::LabeledAttributes;
    use Moose::Exporter;
    $INC{'MyApp/MooseX/LabeledAttributes.pm'} = 1;

    # what is the secret sauce?
}

do {
    package MyClass::LabeledURL;
    use Moose;
    use MyApp::MooseX::LabeledAttributes default => 'no label';

    has name => (
        is => 'ro',
    );

    has url => (
        is    => 'ro',
        label => 'overridden',
    );

    no Moose;
    no MyApp::MooseX::LabeledAttributes;
};

do {
    package MyClass::LabeledPost;
    use Moose;
    use MyApp::MooseX::LabeledAttributes default => 'TODO!';

    has name => (
        is => 'ro',
    );

    has body => (
        is    => 'ro',
        label => 'nevermind...',
    );

    no Moose;
    no MyApp::MooseX::LabeledAttributes;
};

my $url_meta = MyClass::LabeledURL->meta;
is($meta->get_attribute('name')->label, 'no label');
is($meta->get_attribute('url')->label, 'overridden');

my $post_meta = MyClass::LabeledPost->meta;
is($meta->get_attribute('name')->label, 'TODO!');
is($meta->get_attribute('body')->label, 'nevermind...');

done_testing;