Include method name in immutable methods (fixes #49680)
[gitmo/Class-MOP.git] / t / 070_immutable_metaclass.t
index 8d57f5d..e6f716e 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 73;
+use Test::More tests => 76;
 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" );
 }
 
@@ -265,3 +285,30 @@ use Class::MOP;
         '... got the right list of attributes'
     );
 }
+
+# This test probably needs to go last since it will muck up the Foo class
+{
+    my $meta = Foo->meta;
+
+    $meta->make_mutable;
+    $meta->make_immutable(
+        inline_accessors   => 0,
+        inline_constructor => 0,
+        constructor_name   => 'newer',
+    );
+
+    is_deeply(
+        { $meta->immutable_options },
+        {
+            inline_accessors   => 0,
+            inline_constructor => 0,
+            inline_destructor  => 0,
+            debug              => 0,
+            immutable_trait    => 'Class::MOP::Class::Immutable::Trait',
+            constructor_name   => 'newer',
+            constructor_class  => 'Class::MOP::Method::Constructor',
+            destructor_class   => undef,
+        },
+        'custom immutable_options are returned by immutable_options accessor'
+    );
+}