return $meta;
}
-sub create_anon_class {
- my ($class, %options) = @_;
- require Digest::MD5;
- my $package_name = 'Class::MOP::Class::__ANON__::' . Digest::MD5::md5_hex({} . time() . $$ . rand());
- return $class->create($package_name, '0.00', %options);
+{
+ my $ANON_CLASS_SERIAL = 0;
+ sub create_anon_class {
+ my ($class, %options) = @_;
+ my $package_name = 'Class::MOP::Class::__ANON__::SERIAL::' . ++$ANON_CLASS_SERIAL;
+ return $class->create($package_name, '0.00', %options);
+ }
}
## Attribute readers
my $anon_class = Class::MOP::Class->create_anon_class();
isa_ok($anon_class, 'Class::MOP::Class');
-like($anon_class->name, qr/Class::MOP::Class::__ANON__::[0-9a-f]/, '... got an anon class package name');
+like($anon_class->name, qr/Class::MOP::Class::__ANON__::SERIAL::[0-9]+/, '... got an anon class package name');
lives_ok {
$anon_class->add_method('foo' => sub { "__ANON__::foo" });