the __MOP__ slot should be used for any weak class, not just anon
[gitmo/Class-MOP.git] / t / 048_anon_class_create_init.t
index e24319c..4cda746 100644 (file)
@@ -117,4 +117,20 @@ my $instance;
     }
 }
 
+{
+    my $meta = Class::MOP::Class->create(
+        'Baz',
+        weaken => 1,
+    );
+    $instance = $meta->new_object;
+}
+{
+    my $meta = Class::MOP::class_of($instance);
+    Scalar::Util::weaken($meta);
+    ok($meta, "weak class is kept alive by existing instances");
+
+    undef $instance;
+    ok(!$meta, "weak class is collected once instances go away");
+}
+
 done_testing;