Skip to content

Instantly share code, notes, and snippets.

@carloslima
Created February 3, 2012 06:36
Show Gist options
  • Save carloslima/1728543 to your computer and use it in GitHub Desktop.
Save carloslima/1728543 to your computer and use it in GitHub Desktop.
This is a standard Ubuntu 11.04 box
~$ perl -v
This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi
(with 53 registered patches, see perl -V for more detail)
Copyright 1987-2009, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
~$ perl -MMoose -E'say Moose->VERSION'
1.23
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Test::More tests => 3;
use Test::NoWarnings;
use Test::LeakTrace;
use Moose;
do {
package DummyRole;
use Moose::Role;
sub myname { "I'm a role" }
};
subtest "Passing" => sub {
leaks_cmp_ok {
my $a = { a=>1 };
my $b = { a=>$a, b=>1 };
$a->{b} = $a;
} '=', 3, "Test::LeakTrace sanity check";
no_leaks_ok {
my $a = "Abc";
my $b = {a=>5};
} "Test::LeakTrace sanity check";
no_leaks_ok {
Moose::Meta::Class->create_anon_class->new_object;
} "Plain anonymous class is leak-free";
no_leaks_ok {
Moose::Meta::Role->initialize('DummyRole2')
} 'Plain role is leak-free';
no_leaks_ok {
Moose::Meta::Class->create('DummyClass2')->new_object;
} "Plain class is leak-free";
};
subtest "Failing" => sub {
no_leaks_ok {
Moose::Meta::Class->create('DummyClass', roles => ['DummyRole'])->new_object;
} "Plain class with role is leak-free";
no_leaks_ok {
Moose::Meta::Role->create_anon_role;
} 'Plain anonymous role is leak-free';
no_leaks_ok {
my $o = Moose::Meta::Class->create_anon_class;
$o->make_immutable;
$o->new_object
} "Plain immutable anonymous class is leak-free";
};
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Moose;
while(1) {
#Moose::Meta::Class->create_anon_class; #works fine
Moose::Meta::Class->create_anon_class->make_immutable; #leaks
sleep(0.7);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment