X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F073_make_mutable.t;h=8880f27d2f9a6e08f0a350be9eb3597c770d46df;hb=cb75020f6a75898378d873583561654f3519ea92;hp=66b432a96ec3fa08c861b964af88026fee490c6c;hpb=229910b5cf0bee35e072db0f8305e799241d4366;p=gitmo%2FClass-MOP.git diff --git a/t/073_make_mutable.t b/t/073_make_mutable.t index 66b432a..8880f27 100644 --- a/t/073_make_mutable.t +++ b/t/073_make_mutable.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 108; +use Test::More tests => 112; use Test::Exception; use Scalar::Util; @@ -45,28 +45,33 @@ BEGIN { { my $meta = Baz->meta; is($meta->name, 'Baz', '... checking the Baz metaclass'); - my @orig_keys = sort keys %$meta; + my @orig_keys = sort grep { !/^_/ } keys %$meta; 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'); ok($meta->get_method_map->{new}, '... inlined constructor created'); + ok($meta->has_method('new'), '... inlined constructor created for sure'); 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'); ok(!$meta->get_method_map->{new}, '... inlined constructor removed'); + ok(!$meta->has_method('new'), '... inlined constructor removed for sure'); - my @new_keys = sort keys %$meta; + my @new_keys = sort grep { !/^_/ } keys %$meta; is_deeply(\@orig_keys, \@new_keys, '... no straneous hashkeys'); isa_ok($meta, 'Class::MOP::Class', '... Baz->meta isa Class::MOP::Class'); ok( $meta->add_method('xyz', sub{'xxx'}), '... added method'); is( Baz->xyz, 'xxx', '... method xyz works'); + + ok(! $meta->has_method('zxy') ,'... we dont have the aliased method yet'); ok( $meta->alias_method('zxy',sub{'xxx'}),'... aliased method'); + ok(! $meta->has_method('zxy') ,'... the aliased method does not register (correctly)'); is( Baz->zxy, 'xxx', '... method zxy works'); ok( $meta->remove_method('xyz'), '... removed method'); ok(! $meta->remove_method('zxy'), '... removed aliased method'); @@ -127,7 +132,7 @@ BEGIN { 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_keys = sort grep { !/^_/ } keys %$meta; my @orig_meths = sort { $a->{name} cmp $b->{name} } $meta->compute_all_applicable_methods; ok($meta->is_anon_class, 'We have an anon metaclass'); @@ -151,7 +156,7 @@ BEGIN { ok($meta->is_anon_class, '... still marked as an anon class'); my $instance = $meta->new_object; - my @new_keys = sort keys %$meta; + my @new_keys = sort grep { !/^_/ } keys %$meta; my @new_meths = sort { $a->{name} cmp $b->{name} } $meta->compute_all_applicable_methods; is_deeply(\@orig_keys, \@new_keys, '... no straneous hashkeys');