From: Dave Rolsky Date: Thu, 12 Mar 2009 16:45:03 +0000 (-0500) Subject: Add a test to ensure that the get_write_method returns undef for a read-only attribute X-Git-Tag: 0.78_01~57 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ffba6596d5bace4e80edf9846463053add25220a;p=gitmo%2FClass-MOP.git Add a test to ensure that the get_write_method returns undef for a read-only attribute --- diff --git a/t/005_attributes.t b/t/005_attributes.t index 12e2a01..dad4d54 100644 --- a/t/005_attributes.t +++ b/t/005_attributes.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 70; +use Test::More tests => 73; use Test::Exception; use Class::MOP; @@ -88,6 +88,23 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly'); } { + package Foo2; + use metaclass; + + my $meta = Foo2->meta; + $meta->add_attribute( + Class::MOP::Attribute->new( '$foo2' => ( reader => 'foo2' ) ) ); + + ::ok( $meta->has_method('foo2'), '... a reader has been created' ); + + my $attr = $meta->get_attribute('$foo2'); + ::is( $attr->get_read_method, 'foo2', + '... got the right read method for Foo2' ); + ::is( $attr->get_write_method, undef, + '... got undef for the writer with a read-only attribute in Foo2' ); +} + +{ my $meta = Baz->meta; isa_ok($meta, 'Class::MOP::Class');