File: positional_args_and_hr.t

package info (click to toggle)
libmoosex-traits-pluggable-perl 0.10-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 204 kB
  • sloc: perl: 2,102; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 690 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;
use Test::More tests => 2;

{
    package Trait;
    use Moose::Role;
    has 'foo' => (
        is       => 'ro',
        isa      => 'Str',
        required => 1,
    );

    package Parent;
    use Moose;

    sub BUILDARGS {
        pop(@_);
    }

    package Class;
    use Moose;
    use Test::More;
    extends 'Parent';
    with 'MooseX::Traits::Pluggable';
    override BUILDARGS => sub {
        my ($self, $param1) = @_;
        is $param1, 'Positional value', 'Positional value preserved';
        super();
    };
}

my $i = Class->new_with_traits('Positional value',
    { foo => 'bar', traits => 'Trait' }
);
is $i->foo, 'bar', 'Normal args work';