Import tests for attribute from Mouse's tests
[gitmo/Mouse.git] / t / 020_attributes / failing / 030_non_alpha_attr_names.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 12;
5
6 {
7     package Foo;
8     use Mouse;
9     has 'type' => (
10         required => 0,
11         reader   => 'get_type',
12         default  => 1,
13     );
14
15     has '@type' => (
16         required => 0,
17         reader   => 'get_at_type',
18         default  => 2,
19     );
20
21     has 'has spaces' => (
22         required => 0,
23         reader   => 'get_hs',
24         default  => 42,
25     );
26
27     no Mouse;
28 }
29
30 {
31     my $foo = Foo->new;
32
33     ok( Foo->meta->has_attribute($_), "Foo has '$_' attribute" )
34         for 'type', '@type', 'has spaces';
35
36     is( $foo->get_type,    1,  q{'type' attribute default is 1} );
37     is( $foo->get_at_type, 2,  q{'@type' attribute default is 1} );
38     is( $foo->get_hs,      42, q{'has spaces' attribute default is 42} );
39
40     Foo->meta->make_immutable, redo if Foo->meta->is_mutable;
41 }