RT#83929: fix memory leak in union types
[gitmo/Moose.git] / xt / author / memory_leaks.t
index 0c0d04a..d4e0a75 100644 (file)
@@ -7,6 +7,7 @@ use Test::Memory::Cycle;
 
 use Moose ();
 use Moose::Util qw( apply_all_roles );
+use Moose::Util::TypeConstraints;
 
 {
     package MyRole;
@@ -99,4 +100,13 @@ no_leaks_ok(
     memory_cycle_ok($anon_role, 'anon role meta object is cycle-free' );
 }
 
+{
+    my $Str = find_type_constraint('Str');
+    my $Undef = find_type_constraint('Undef');
+    my $Str_or_Undef = Moose::Meta::TypeConstraint::Union->new(
+        type_constraints => [ $Str, $Undef ] );
+    memory_cycle_ok($Str_or_Undef, 'union types do not leak');
+}
+
+
 done_testing;