From: Dave Rolsky Date: Sun, 17 Jan 2010 16:37:05 +0000 (-0600) Subject: Add test for non-alphanumeric attr names (with inlining) X-Git-Tag: 0.98~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=55743c1ae7c9a4e12c957ccdc7174594deb4d271;p=gitmo%2FClass-MOP.git Add test for non-alphanumeric attr names (with inlining) --- diff --git a/t/025_attribute_non_alpha_name.t b/t/025_attribute_non_alpha_name.t new file mode 100644 index 0000000..98e411e --- /dev/null +++ b/t/025_attribute_non_alpha_name.t @@ -0,0 +1,34 @@ +use strict; +use warnings; + +use Class::MOP; + +use Test::More; + +{ + package Foo; + use metaclass; + + Foo->meta->add_attribute( '@foo', accessor => 'foo' ); + Foo->meta->add_attribute( '!bar', reader => 'bar' ); + Foo->meta->add_attribute( '%baz', reader => 'baz' ); +} + +{ + my $meta = Foo->meta; + + for my $name ( '@foo', '!bar', '%baz' ) { + ok( + $meta->has_attribute($name), + "Foo has $name attribute" + ); + + my $meth = substr $name, 1; + ok( $meta->has_method($meth), 'Foo has $meth method' ); + } + + $meta->make_immutable, redo + unless $meta->is_immutable; +} + +done_testing;