Redo conversion to Test::Fatal
[gitmo/Class-MOP.git] / t / 049_metaclass_reinitialize.t
index 7d8dd50..b739836 100644 (file)
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 
 use Test::More;
-use Test::Exception;
+use Test::Fatal;
 
 {
     package Foo;
@@ -26,23 +26,23 @@ can_ok('Foo', 'meta');
 my $meta = Foo->meta;
 check_meta_sanity($meta, 'Foo');
 
-lives_ok {
+is( exception {
     $meta = $meta->reinitialize($meta->name);
-};
+}, undef );
 check_meta_sanity($meta, 'Foo');
 
-lives_ok {
+is( exception {
     $meta = $meta->reinitialize($meta);
-};
+}, undef );
 check_meta_sanity($meta, 'Foo');
 
-throws_ok {
+like( exception {
     $meta->reinitialize('');
-} qr/You must pass a package name or an existing Class::MOP::Package instance/;
+}, qr/You must pass a package name or an existing Class::MOP::Package instance/ );
 
-throws_ok {
+like( exception {
     $meta->reinitialize($meta->new_object);
-} qr/You must pass a package name or an existing Class::MOP::Package instance/;
+}, qr/You must pass a package name or an existing Class::MOP::Package instance/ );
 
 {
     package Bar::Meta::Method;
@@ -67,9 +67,9 @@ $meta = Bar->meta;
 check_meta_sanity($meta, 'Bar');
 isa_ok(Bar->meta->get_method('foo'), 'Bar::Meta::Method');
 isa_ok(Bar->meta->get_attribute('bar'), 'Bar::Meta::Attribute');
-lives_ok {
+is( exception {
     $meta = $meta->reinitialize('Bar');
-};
+}, undef );
 check_meta_sanity($meta, 'Bar');
 isa_ok(Bar->meta->get_method('foo'), 'Bar::Meta::Method');
 isa_ok(Bar->meta->get_attribute('bar'), 'Bar::Meta::Attribute');
@@ -79,9 +79,9 @@ Bar->meta->get_attribute('bar')->tset('OOF');
 
 is(Bar->meta->get_method('foo')->test, 'FOO');
 is(Bar->meta->get_attribute('bar')->tset, 'OOF');
-lives_ok {
+is( exception {
     $meta = $meta->reinitialize('Bar');
-};
+}, undef );
 is(Bar->meta->get_method('foo')->test, 'FOO');
 is(Bar->meta->get_attribute('bar')->tset, 'OOF');
 
@@ -107,13 +107,13 @@ $meta = Class::MOP::class_of('Baz');
 check_meta_sanity($meta, 'Baz');
 ok(!$meta->get_method('foo')->isa('Baz::Meta::Method'));
 ok(!$meta->get_attribute('bar')->isa('Baz::Meta::Attribute'));
-lives_ok {
+is( exception {
     $meta = $meta->reinitialize(
         'Baz',
         attribute_metaclass => 'Baz::Meta::Attribute',
         method_metaclass    => 'Baz::Meta::Method'
     );
-};
+}, undef );
 check_meta_sanity($meta, 'Baz');
 isa_ok($meta->get_method('foo'), 'Baz::Meta::Method');
 isa_ok($meta->get_attribute('bar'), 'Baz::Meta::Attribute');
@@ -132,13 +132,13 @@ $meta = Quux->meta;
 check_meta_sanity($meta, 'Quux');
 isa_ok(Quux->meta->get_method('foo'), 'Bar::Meta::Method');
 isa_ok(Quux->meta->get_attribute('bar'), 'Bar::Meta::Attribute');
-throws_ok {
+like( exception {
     $meta = $meta->reinitialize(
         'Quux',
         attribute_metaclass => 'Baz::Meta::Attribute',
         method_metaclass    => 'Baz::Meta::Method',
     );
-} qr/compatible/;
+}, qr/compatible/ );
 
 {
     package Quuux::Meta::Attribute;
@@ -157,12 +157,12 @@ throws_ok {
 $meta = Quuux->meta;
 check_meta_sanity($meta, 'Quuux');
 ok($meta->has_method('bar'));
-lives_ok {
+is( exception {
     $meta = $meta->reinitialize(
         'Quuux',
         attribute_metaclass => 'Quuux::Meta::Attribute',
     );
-};
+}, undef );
 check_meta_sanity($meta, 'Quuux');
 ok(!$meta->has_method('bar'));
 
@@ -189,13 +189,13 @@ ok(!$meta->has_method('bar'));
 
 $meta = Class::MOP::class_of('Blah');
 check_meta_sanity($meta, 'Blah');
-lives_ok {
+is( exception {
     $meta = Class::MOP::Class->reinitialize(
         'Blah',
         attribute_metaclass => 'Blah::Meta::Attribute',
         method_metaclass    => 'Blah::Meta::Method',
     );
-};
+}, undef );
 check_meta_sanity($meta, 'Blah');
 can_ok($meta->get_method('foo'), 'foo');
 is($meta->get_method('foo')->foo, 'TEST');