X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F073_make_mutable.t;h=dca59cd6c1e606fdf886ccf74b963226cfff19c2;hb=41fc2d0fd29483cb704e06198bfaabbcd3e09d08;hp=8880f27d2f9a6e08f0a350be9eb3597c770d46df;hpb=f3938c217bb3ff340d2744a56385df03b6847c3f;p=gitmo%2FClass-MOP.git diff --git a/t/073_make_mutable.t b/t/073_make_mutable.t index 8880f27..dca59cd 100644 --- a/t/073_make_mutable.t +++ b/t/073_make_mutable.t @@ -1,16 +1,12 @@ -#!/usr/bin/perl - use strict; use warnings; -use Test::More tests => 112; +use Test::More tests => 114; use Test::Exception; use Scalar::Util; -BEGIN { - use_ok('Class::MOP'); -} +use Class::MOP; { package Foo; @@ -53,6 +49,8 @@ BEGIN { 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'); + ok($meta->get_immutable_transformer->inlined_constructor, + '... transformer says it did inline the constructor'); lives_ok { $meta->make_mutable; } '... changed Baz to be mutable'; ok($meta->is_mutable, '... our class is mutable'); @@ -60,6 +58,8 @@ BEGIN { 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'); + ok(!$meta->get_immutable_transformer->inlined_constructor, + '... transformer says it did not inline the constructor'); my @new_keys = sort grep { !/^_/ } keys %$meta; is_deeply(\@orig_keys, \@new_keys, '... no straneous hashkeys'); @@ -71,10 +71,10 @@ BEGIN { 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)'); + ok( $meta->has_method('zxy') ,'... the aliased method does register'); 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'); @@ -169,7 +169,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'); @@ -226,3 +226,12 @@ BEGIN { for qw(get_meta_instance compute_all_applicable_attributes class_precedence_list get_method_map ); } + +{ + Foo->meta->make_immutable; + Bar->meta->make_immutable; + Bar->meta->make_mutable; + + isnt( Foo->meta->get_immutable_transformer, Bar->meta->get_immutable_transformer, + 'Foo and Bar should have different immutable transformer objects' ); +}