Test fixes
[gitmo/MooseX-Role-Parameterized.git] / t / 016-trait.t
CommitLineData
34a27044 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More skip_all => "Moose doesn't yet support traits with parameters";
5#use Test::More tests => 2;
6
7do {
8 package MyTrait::Label;
9 use MooseX::Role::Parameterized;
10
11 parameter default => (
12 is => 'rw',
13 isa => 'Str',
14 );
15
16 role {
17 my $p = shift;
18
19 has label => (
20 is => 'rw',
21 isa => 'Str',
22 default => $p->default,
23 );
24 };
25};
26
27do {
28 package MyClass::LabeledURL;
29 use Moose;
30
31 has url => (
32 traits => [
33 'MyTrait::Label' => { default => 'yay' },
34 ],
34a27044 35 );
36};
37
38do {
39 package MyClass::LabeledURL::Redux;
40 use Moose;
34a27044 41
9857cc15 42 has 'url' => (
43 traits => [
44 'MyTrait::Label' => { default => 'yay' },
45 ],
34a27044 46 label => 'overridden',
47 );
48};
49
50is(MyClass::LabeledURL->meta->get_attribute('url')->label, 'yay');
51is(MyClass::LabeledURL::Redux->meta->get_attribute('url')->label, 'overridden');
52