use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
{
package Foo;
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;
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');
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');
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');
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;
$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'));
$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');