From: Dave Rolsky Date: Fri, 11 Sep 2009 15:49:17 +0000 (-0500) Subject: Add some tests for attr names with non-alphanumeric characters in them X-Git-Tag: 0.90~51 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c0a92932d6210dab2f8a54566635eeead53a5a41;p=gitmo%2FMoose.git Add some tests for attr names with non-alphanumeric characters in them --- diff --git a/t/020_attributes/030_non_alpha_attr_names.t b/t/020_attributes/030_non_alpha_attr_names.t new file mode 100644 index 0000000..efbc0fc --- /dev/null +++ b/t/020_attributes/030_non_alpha_attr_names.t @@ -0,0 +1,41 @@ +use strict; +use warnings; + +use Test::More tests => 12; + +{ + package Foo; + use Moose; + has 'type' => ( + required => 0, + reader => 'get_type', + default => 1, + ); + + has '@type' => ( + required => 0, + reader => 'get_at_type', + default => 2, + ); + + has 'has spaces' => ( + required => 0, + reader => 'get_hs', + default => 42, + ); + + no Moose; +} + +{ + my $foo = Foo->new; + + 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} ); + + Foo->meta->make_immutable, redo if Foo->meta->is_mutable; +}