Class::MOP with XS
[gitmo/Class-MOP.git] / t / 073_make_mutable.t
index 118bcaf..e753208 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 101;
+use Test::More tests => 104;
 use Test::Exception;
 
 use Scalar::Util;
@@ -47,12 +47,12 @@ BEGIN {
     is($meta->name, 'Baz', '... checking the Baz metaclass');
     my @orig_keys = sort keys %$meta;
 
-    lives_ok {$meta->make_immutable() } '... changed Baz to be immutable';
+    lives_ok {$meta->make_immutable; } '... changed Baz to be immutable';
     ok(!$meta->is_mutable,              '... our class is no longer mutable');
     ok($meta->is_immutable,             '... our class is now immutable');
     ok(!$meta->make_immutable,          '... make immutable now returns nothing');
 
-    lives_ok { $meta->make_mutable() }  '... changed Baz to be mutable';
+    lives_ok { $meta->make_mutable; }  '... changed Baz to be mutable';
     ok($meta->is_mutable,               '... our class is mutable');
     ok(!$meta->is_immutable,            '... our class is not immutable');
     ok(!$meta->make_mutable,            '... make mutable now returns nothing');
@@ -67,7 +67,7 @@ BEGIN {
     ok( $meta->alias_method('zxy',sub{'xxx'}),'... aliased method');
     is( Baz->zxy, 'xxx',                      '... method zxy works');
     ok( $meta->remove_method('xyz'),          '... removed method');
-    ok( $meta->remove_method('zxy'),          '... removed aliased method');
+    ok(! $meta->remove_method('zxy'),          '... removed aliased method');
 
     ok($meta->add_attribute('fickle', accessor => 'fickle'), '... added attribute');
     ok(Baz->can('fickle'),                '... Baz can fickle');
@@ -118,14 +118,17 @@ BEGIN {
              class_precedence_list  get_method_map );
 }
 
-
-
 {
 
+    ok(Baz->meta->is_immutable,  'Superclass is immutable');
     my $meta = Baz->meta->create_anon_class(superclasses => ['Baz']);
     my @orig_keys  = sort keys %$meta;
-    my @orig_meths = sort $meta->compute_all_applicable_methods;
+    my @orig_meths = sort { $a->{name} cmp $b->{name} }
+      $meta->compute_all_applicable_methods;
     ok($meta->is_anon_class,                  'We have an anon metaclass');
+    ok($meta->is_mutable,  '... our anon class is mutable');
+    ok(!$meta->is_immutable,  '... our anon class is not immutable');
+
     lives_ok {$meta->make_immutable(
                                     inline_accessor    => 1,
                                     inline_destructor  => 0,
@@ -144,7 +147,8 @@ BEGIN {
     my $instance = $meta->new_object;
 
     my @new_keys  = sort keys %$meta;
-    my @new_meths = sort $meta->compute_all_applicable_methods;
+    my @new_meths = sort { $a->{name} cmp $b->{name} }
+      $meta->compute_all_applicable_methods;
     is_deeply(\@orig_keys, \@new_keys, '... no straneous hashkeys');
     is_deeply(\@orig_meths, \@new_meths, '... no straneous methods');
 
@@ -155,7 +159,7 @@ BEGIN {
     ok( $meta->alias_method('zxy',sub{'xxx'}),'... aliased method');
     is( $instance->zxy, 'xxx',                '... method zxy works');
     ok( $meta->remove_method('xyz'),          '... removed method');
-    ok( $meta->remove_method('zxy'),          '... removed aliased method');
+    ok( !$meta->remove_method('zxy'),          '... removed aliased method');
 
     ok($meta->add_attribute('fickle', accessor => 'fickle'), '... added attribute');
     ok($instance->can('fickle'),          '... instance can fickle');