From: Dave Rolsky Date: Thu, 10 Sep 2009 17:47:45 +0000 (-0500) Subject: make immutable_options part of the regular CMOP::Class API and add some tests for it X-Git-Tag: 0.92_01~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=07a0558391d3232b2fccdbb57d64230087363555;p=gitmo%2FClass-MOP.git make immutable_options part of the regular CMOP::Class API and add some tests for it --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 722dfdd..a23b4c4 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -879,6 +879,8 @@ sub is_pristine { sub is_mutable { 1 } sub is_immutable { 0 } +sub immutable_options { %{ $_[0]{__immutable}{options} || {} } } + sub _immutable_options { my ( $self, @args ) = @_; diff --git a/lib/Class/MOP/Class/Immutable/Trait.pm b/lib/Class/MOP/Class/Immutable/Trait.pm index 471cc6a..724ca59 100644 --- a/lib/Class/MOP/Class/Immutable/Trait.pm +++ b/lib/Class/MOP/Class/Immutable/Trait.pm @@ -15,8 +15,6 @@ our $AUTHORITY = 'cpan:STEVAN'; # the original class of the metaclass instance sub _get_mutable_metaclass_name { $_[0]{__immutable}{original_class} } -sub immutable_options { %{ $_[0]{__immutable}{options} } } - sub is_mutable { 0 } sub is_immutable { 1 } diff --git a/t/070_immutable_metaclass.t b/t/070_immutable_metaclass.t index 8d57f5d..4f6663b 100644 --- a/t/070_immutable_metaclass.t +++ b/t/070_immutable_metaclass.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 73; +use Test::More tests => 75; use Test::Exception; use Class::MOP; @@ -40,6 +40,11 @@ use Class::MOP; my $meta = Foo->meta; my $original_metaclass_name = ref $meta; + is_deeply( + { $meta->immutable_options }, {}, + 'immutable_options is empty before a class is made_immutable' + ); + $meta->make_immutable; my $immutable_metaclass = $meta->_immutable_metaclass->meta; @@ -51,6 +56,21 @@ use Class::MOP; is( $immutable_class_name->meta, $immutable_metaclass, '... immutable_metaclass meta hack works' ); + is_deeply( + { $meta->immutable_options }, + { + inline_accessors => 1, + inline_constructor => 1, + inline_destructor => 0, + debug => 0, + immutable_trait => 'Class::MOP::Class::Immutable::Trait', + constructor_name => 'new', + constructor_class => 'Class::MOP::Method::Constructor', + destructor_class => undef, + }, + 'immutable_options is empty before a class is made_immutable' + ); + isa_ok( $meta, "Class::MOP::Class" ); }