X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F073_make_mutable.t;h=4070b5c5082b06fa8cdf92526421b34fc16a1b1f;hb=8371f3de4e9525ab751008dca4a89e6df65345a6;hp=0ee94352bcb729169edaaa31c349b200f6515fa1;hpb=d65739b4429cbd77a5400b2ac8273af504fcf3da;p=gitmo%2FClass-MOP.git diff --git a/t/073_make_mutable.t b/t/073_make_mutable.t index 0ee9435..4070b5c 100644 --- a/t/073_make_mutable.t +++ b/t/073_make_mutable.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Fatal; +use Test::Exception; use Scalar::Util; @@ -45,7 +45,7 @@ use Class::MOP; # Since this has no default it won't be present yet, but it will # be after the class is made immutable. - ok ! exception { $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'); @@ -53,7 +53,7 @@ use Class::MOP; ok($meta->has_method('new'), '... inlined constructor created for sure'); is_deeply([ map { $_->name } $meta->_inlined_methods ], [ 'new' ], '... really, i mean it'); - ok ! exception { $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'); @@ -75,7 +75,7 @@ use Class::MOP; my $reef = \ 'reef'; ok($meta->add_package_symbol('$ref', $reef), '... added package symbol'); is($meta->get_package_symbol('$ref'), $reef, '... values match'); - ok ! exception { $meta->remove_package_symbol('$ref') }, '... removed it'; + lives_ok { $meta->remove_package_symbol('$ref') } '... removed it'; isnt($meta->get_package_symbol('$ref'), $reef, '... values match'); ok( my @supers = $meta->superclasses, '... got the superclasses okay'); @@ -88,30 +88,30 @@ use Class::MOP; for qw(get_meta_instance get_all_attributes class_precedence_list ); - ok ! exception { $meta->make_immutable; }, '... changed Baz to be immutable again'; + lives_ok {$meta->make_immutable; } '... changed Baz to be immutable again'; ok($meta->get_method('new'), '... inlined constructor recreated'); } { my $meta = Baz->meta; - ok ! exception { $meta->make_immutable() }, 'Changed Baz to be immutable'; - ok ! exception { $meta->make_mutable() }, '... changed Baz to be mutable'; - ok ! exception { $meta->make_immutable() }, '... changed Baz to be immutable'; + lives_ok { $meta->make_immutable() } 'Changed Baz to be immutable'; + lives_ok { $meta->make_mutable() } '... changed Baz to be mutable'; + lives_ok { $meta->make_immutable() } '... changed Baz to be immutable'; - ok exception { $meta->add_method('xyz', sub{'xxx'}) }, '... exception thrown as expected'; + dies_ok{ $meta->add_method('xyz', sub{'xxx'}) } '... exception thrown as expected'; - ok exception { + dies_ok { $meta->add_attribute('fickle', accessor => 'fickle') - }, '... exception thrown as expected'; - ok exception { $meta->remove_attribute('fickle') }, '... exception thrown as expected'; + } '... exception thrown as expected'; + dies_ok { $meta->remove_attribute('fickle') } '... exception thrown as expected'; my $reef = \ 'reef'; - ok exception { $meta->add_package_symbol('$ref', $reef) }, '... exception thrown as expected'; - ok exception { $meta->remove_package_symbol('$ref') }, '... exception thrown as expected'; + dies_ok { $meta->add_package_symbol('$ref', $reef) } '... exception thrown as expected'; + dies_ok { $meta->remove_package_symbol('$ref') } '... exception thrown as expected'; ok( my @supers = $meta->superclasses, '... got the superclasses okay'); - ok exception { $meta->superclasses('Foo') }, '... set the superclasses'; + dies_ok { $meta->superclasses('Foo') } '... set the superclasses'; ok( $meta->$_ , "... ${_} works") for qw(get_meta_instance get_all_attributes @@ -128,17 +128,17 @@ use Class::MOP; ok($meta->is_mutable, '... our anon class is mutable'); ok(!$meta->is_immutable, '... our anon class is not immutable'); - ok ! exception {$meta->make_immutable( + lives_ok {$meta->make_immutable( inline_accessor => 1, inline_destructor => 0, inline_constructor => 1, ) - }, '... changed class to be immutable'; + } '... changed class 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 ! exception { $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'); @@ -164,7 +164,7 @@ use Class::MOP; my $reef = \ 'reef'; ok($meta->add_package_symbol('$ref', $reef), '... added package symbol'); is($meta->get_package_symbol('$ref'), $reef, '... values match'); - ok ! exception { $meta->remove_package_symbol('$ref') }, '... removed it'; + lives_ok { $meta->remove_package_symbol('$ref') } '... removed it'; isnt($meta->get_package_symbol('$ref'), $reef, '... values match'); ok( my @supers = $meta->superclasses, '... got the superclasses okay'); @@ -183,29 +183,28 @@ use Class::MOP; { my $meta = Baz->meta->create_anon_class(superclasses => ['Baz']); - ok ! exception { - $meta->make_immutable( - inline_accessor => 1, - inline_destructor => 0, - inline_constructor => 1, - ) - }, '... changed class to be immutable'; - ok ! exception { $meta->make_mutable() }, '... changed class to be mutable'; - ok ! exception { $meta->make_immutable }, '... changed class to be immutable'; + lives_ok {$meta->make_immutable( + inline_accessor => 1, + inline_destructor => 0, + inline_constructor => 1, + ) + } '... changed class to be immutable'; + lives_ok { $meta->make_mutable() } '... changed class to be mutable'; + lives_ok {$meta->make_immutable } '... changed class to be immutable'; - ok exception { $meta->add_method('xyz', sub{'xxx'}) }, '... exception thrown as expected'; + dies_ok{ $meta->add_method('xyz', sub{'xxx'}) } '... exception thrown as expected'; - ok exception { + dies_ok { $meta->add_attribute('fickle', accessor => 'fickle') - }, '... exception thrown as expected'; - ok exception { $meta->remove_attribute('fickle') }, '... exception thrown as expected'; + } '... exception thrown as expected'; + dies_ok { $meta->remove_attribute('fickle') } '... exception thrown as expected'; my $reef = \ 'reef'; - ok exception { $meta->add_package_symbol('$ref', $reef) }, '... exception thrown as expected'; - ok exception { $meta->remove_package_symbol('$ref') }, '... exception thrown as expected'; + dies_ok { $meta->add_package_symbol('$ref', $reef) } '... exception thrown as expected'; + dies_ok { $meta->remove_package_symbol('$ref') } '... exception thrown as expected'; ok( my @supers = $meta->superclasses, '... got the superclasses okay'); - ok exception { $meta->superclasses('Foo') }, '... set the superclasses'; + dies_ok { $meta->superclasses('Foo') } '... set the superclasses'; ok( $meta->$_ , "... ${_} works") for qw(get_meta_instance get_all_attributes