Commit | Line | Data |
4060c871 |
1 | use strict; |
1f5ce14a |
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; |
4060c871 |
5 | use warnings; |
6 | |
1f5ce14a |
7 | use Test::More; |
8 | use Test::Mouse; |
4060c871 |
9 | |
10 | { |
11 | package Foo; |
12 | use Mouse; |
13 | has 'type' => ( |
14 | required => 0, |
15 | reader => 'get_type', |
16 | default => 1, |
17 | ); |
18 | |
1f5ce14a |
19 | # Assigning types to these non-alpha attrs exposed a bug in Mouse. |
4060c871 |
20 | has '@type' => ( |
1f5ce14a |
21 | isa => 'Str', |
4060c871 |
22 | required => 0, |
23 | reader => 'get_at_type', |
1f5ce14a |
24 | writer => 'set_at_type', |
25 | default => 'at type', |
4060c871 |
26 | ); |
27 | |
28 | has 'has spaces' => ( |
1f5ce14a |
29 | isa => 'Int', |
4060c871 |
30 | required => 0, |
31 | reader => 'get_hs', |
32 | default => 42, |
33 | ); |
34 | |
1f5ce14a |
35 | has '!req' => ( |
36 | required => 1, |
37 | reader => 'req' |
38 | ); |
39 | |
4060c871 |
40 | no Mouse; |
41 | } |
42 | |
1f5ce14a |
43 | with_immutable { |
4060c871 |
44 | ok( Foo->meta->has_attribute($_), "Foo has '$_' attribute" ) |
45 | for 'type', '@type', 'has spaces'; |
46 | |
1f5ce14a |
47 | my $foo = Foo->new( '!req' => 42 ); |
48 | |
49 | is( $foo->get_type, 1, q{'type' attribute default is 1} ); |
50 | is( $foo->get_at_type, 'at type', q{'@type' attribute default is 1} ); |
51 | is( $foo->get_hs, 42, q{'has spaces' attribute default is 42} ); |
4060c871 |
52 | |
1f5ce14a |
53 | $foo = Foo->new( |
54 | type => 'foo', |
55 | '@type' => 'bar', |
56 | 'has spaces' => 200, |
57 | '!req' => 84, |
58 | ); |
59 | |
60 | isa_ok( $foo, 'Foo' ); |
61 | is( $foo->get_at_type, 'bar', q{reader for '@type'} ); |
62 | is( $foo->get_hs, 200, q{reader for 'has spaces'} ); |
63 | |
64 | $foo->set_at_type(99); |
65 | is( $foo->get_at_type, 99, q{writer for '@type' worked} ); |
4060c871 |
66 | } |
1f5ce14a |
67 | 'Foo'; |
68 | |
69 | done_testing; |