X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F020_attributes%2F030_non_alpha_attr_names.t;h=66f4fe2c16ed729cdebd31d1e32598eb6d0bf956;hb=fde8e43f95fe996fbc2a778aa259feeb04552171;hp=81105a834c2f5a99f2896568817042b88ea3b6c8;hpb=0bdc9d38dfd3de07aad929f6629f8fa65d434c27;p=gitmo%2FMouse.git diff --git a/t/020_attributes/030_non_alpha_attr_names.t b/t/020_attributes/030_non_alpha_attr_names.t index 81105a8..66f4fe2 100644 --- a/t/020_attributes/030_non_alpha_attr_names.t +++ b/t/020_attributes/030_non_alpha_attr_names.t @@ -1,7 +1,11 @@ use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use warnings; -use Test::More tests => 12; +use Test::More; +use Test::Mouse; { package Foo; @@ -12,30 +16,54 @@ use Test::More tests => 12; default => 1, ); + # Assigning types to these non-alpha attrs exposed a bug in Mouse. has '@type' => ( + isa => 'Str', required => 0, reader => 'get_at_type', - default => 2, + writer => 'set_at_type', + default => 'at type', ); has 'has spaces' => ( + isa => 'Int', required => 0, reader => 'get_hs', default => 42, ); + has '!req' => ( + required => 1, + reader => 'req' + ); + no Mouse; } -{ - my $foo = Foo->new; - +with_immutable { ok( Foo->meta->has_attribute($_), "Foo has '$_' attribute" ) for 'type', '@type', 'has spaces'; - is( $foo->get_type, 1, q{'type' attribute default is 1} ); - is( $foo->get_at_type, 2, q{'@type' attribute default is 1} ); - is( $foo->get_hs, 42, q{'has spaces' attribute default is 42} ); + my $foo = Foo->new( '!req' => 42 ); + + is( $foo->get_type, 1, q{'type' attribute default is 1} ); + is( $foo->get_at_type, 'at type', q{'@type' attribute default is 1} ); + is( $foo->get_hs, 42, q{'has spaces' attribute default is 42} ); - Foo->meta->make_immutable, redo if Foo->meta->is_mutable; + $foo = Foo->new( + type => 'foo', + '@type' => 'bar', + 'has spaces' => 200, + '!req' => 84, + ); + + isa_ok( $foo, 'Foo' ); + is( $foo->get_at_type, 'bar', q{reader for '@type'} ); + is( $foo->get_hs, 200, q{reader for 'has spaces'} ); + + $foo->set_at_type(99); + is( $foo->get_at_type, 99, q{writer for '@type' worked} ); } +'Foo'; + +done_testing;