Regenerate test files
[gitmo/Mouse.git] / t / 020_attributes / 030_non_alpha_attr_names.t
CommitLineData
4060c871 1use strict;
fde8e43f 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
4060c871 5use warnings;
6
fde8e43f 7use Test::More;
8use 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
fde8e43f 19 # Assigning types to these non-alpha attrs exposed a bug in Mouse.
4060c871 20 has '@type' => (
fde8e43f 21 isa => 'Str',
4060c871 22 required => 0,
23 reader => 'get_at_type',
fde8e43f 24 writer => 'set_at_type',
25 default => 'at type',
4060c871 26 );
27
28 has 'has spaces' => (
fde8e43f 29 isa => 'Int',
4060c871 30 required => 0,
31 reader => 'get_hs',
32 default => 42,
33 );
34
fde8e43f 35 has '!req' => (
36 required => 1,
37 reader => 'req'
38 );
39
4060c871 40 no Mouse;
41}
42
fde8e43f 43with_immutable {
4060c871 44 ok( Foo->meta->has_attribute($_), "Foo has '$_' attribute" )
45 for 'type', '@type', 'has spaces';
46
fde8e43f 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
fde8e43f 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}
fde8e43f 67'Foo';
68
69done_testing;