use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
use Class::MOP;
}
{
+ my $meta = Class::MOP::Class->create_anon_class;
+ $meta->make_immutable;
+ $instance = $meta->name->new;
+}
+{
+ my $meta = Class::MOP::class_of($instance);
+ Scalar::Util::weaken($meta);
+ ok($meta, "anon class is kept alive by existing instances (immutable)");
+
+ undef $instance;
+ ok(!$meta, "anon class is collected once instances go away (immutable)");
+}
+
+{
$instance = Class::MOP::Class->create('Foo')->new_object;
my $meta = Class::MOP::Class->create_anon_class(superclasses => ['Foo']);
$meta->rebless_instance($instance);
ok(Class::MOP::class_of($meta_name), "metaclass still exists");
{
my $bar_meta;
- lives_ok {
+ is( exception {
$bar_meta = $meta_name->initialize('Bar');
- } "we can use the name on its own";
+ }, undef, "we can use the name on its own" );
isa_ok($bar_meta, $meta_name);
}
}