Remove our (now broken) dzil GatherDir subclass
[gitmo/Moose.git] / t / attributes / non_alpha_attr_names.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Moose;
6
7 {
8     package Foo;
9     use Moose;
10     has 'type' => (
11         required => 0,
12         reader   => 'get_type',
13         default  => 1,
14     );
15
16     # Assigning types to these non-alpha attrs exposed a bug in Moose.
17     has '@type' => (
18         isa      => 'Str',
19         required => 0,
20         reader   => 'get_at_type',
21         writer   => 'set_at_type',
22         default  => 'at type',
23     );
24
25     has 'has spaces' => (
26         isa      => 'Int',
27         required => 0,
28         reader   => 'get_hs',
29         default  => 42,
30     );
31
32     has '!req' => (
33         required => 1,
34         reader   => 'req'
35     );
36
37     no Moose;
38 }
39
40 with_immutable {
41     ok( Foo->meta->has_attribute($_), "Foo has '$_' attribute" )
42         for 'type', '@type', 'has spaces';
43
44     my $foo = Foo->new( '!req' => 42 );
45
46     is( $foo->get_type,    1,         q{'type' attribute default is 1} );
47     is( $foo->get_at_type, 'at type', q{'@type' attribute default is 1} );
48     is( $foo->get_hs, 42, q{'has spaces' attribute default is 42} );
49
50     $foo = Foo->new(
51         type         => 'foo',
52         '@type'      => 'bar',
53         'has spaces' => 200,
54         '!req'       => 84,
55     );
56
57     isa_ok( $foo, 'Foo' );
58     is( $foo->get_at_type, 'bar', q{reader for '@type'} );
59     is( $foo->get_hs,      200, q{reader for 'has spaces'} );
60
61     $foo->set_at_type(99);
62     is( $foo->get_at_type, 99, q{writer for '@type' worked} );
63 }
64 'Foo';
65
66 done_testing;