File: 008_RT56837.t

package info (click to toggle)
libmouse-perl 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,156 kB
  • sloc: perl: 14,569; ansic: 218; makefile: 8
file content (28 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (8)
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
#!perl
# This test is contributed by Sanko Robinson.
# https://rt.cpan.org/Public/Bug/Display.html?id=56837
# "Role application to instance with init_arg'd attributes"
use strict;
use Test::More tests => 2;

{
    package Admin;
    use Mouse::Role;
    sub shutdown {1}
}
{
    package User;
    use Mouse;
    has 'name' =>
        (isa => 'Str', is => 'ro', init_arg => 'Name', required => 1);
}

package main;
my $tim = User->new(Name => 'Tim');

Admin->meta->apply($tim);

ok($tim->can('shutdown'),
    'The role was successfully composed at the object level');
is($tim->name, 'Tim',
    '... attribute with init_arg was re-initialized correctly');