Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 020_attributes / 029_accessor_context.t
1 #!/usr/bin/perl
2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
5
6 use strict;
7 use warnings;
8 use Test::More;
9 use Test::Exception;
10
11 lives_ok {
12     package My::Class;
13     use Mouse;
14
15     has s_rw => (
16         is => 'rw',
17     );
18
19     has s_ro => (
20         is => 'ro',
21     );
22
23     has a_rw => (
24         is  => 'rw',
25         isa => 'ArrayRef',
26
27         auto_deref => 1,
28     );
29
30     has a_ro => (
31         is  => 'ro',
32         isa => 'ArrayRef',
33
34         auto_deref => 1,
35     );
36
37     has h_rw => (
38         is  => 'rw',
39         isa => 'HashRef',
40
41         auto_deref => 1,
42     );
43
44     has h_ro => (
45         is  => 'ro',
46         isa => 'HashRef',
47
48         auto_deref => 1,
49     );
50 } 'class definition';
51
52 lives_ok {
53     my $o = My::Class->new();
54
55     is_deeply [scalar $o->s_rw], [undef], 'uninitialized scalar attribute/rw in scalar context';
56     is_deeply [$o->s_rw],        [undef], 'uninitialized scalar attribute/rw in list context';
57     is_deeply [scalar $o->s_ro], [undef], 'uninitialized scalar attribute/ro in scalar context';
58     is_deeply [$o->s_ro],        [undef], 'uninitialized scalar attribute/ro in list context';
59
60
61     is_deeply [scalar $o->a_rw], [undef], 'uninitialized ArrayRef attribute/rw in scalar context';
62     is_deeply [$o->a_rw],        [],      'uninitialized ArrayRef attribute/rw in list context';
63     is_deeply [scalar $o->a_ro], [undef], 'uninitialized ArrayRef attribute/ro in scalar context';
64     is_deeply [$o->a_ro],        [],      'uninitialized ArrayRef attribute/ro in list context';
65
66     is_deeply [scalar $o->h_rw], [undef], 'uninitialized HashRef attribute/rw in scalar context';
67     is_deeply [$o->h_rw],        [],      'uninitialized HashRef attribute/rw in list context';
68     is_deeply [scalar $o->h_ro], [undef], 'uninitialized HashRef attribute/ro in scalar context';
69     is_deeply [$o->h_ro],        [],      'uninitialized HashRef attribute/ro in list context';
70
71 } 'testing';
72
73 done_testing;