Acme-UNIVERSAL-new

 view release on metacpan or  search on metacpan

lib/Acme/UNIVERSAL/new.pm  view on Meta::CPAN

	my $symbol              = shift;
	return unless $symbol && $symbol =~ /^[A-Za-z]/;
	return unless my $ctor  = $symbol->can( 'new' );
	return if        $ctor == \&UNIVERSAL::new;
	return 1;
}

sub get_symbols
{
	my $table = shift;
	return map  { my $name = $_; s/::$//; $name => $_ }
	       grep { /::$/ }
		   keys %$table;
}

sub get_ref
{
	my @refs = ( \(my $foo), {}, [], sub {}, do { local *FOO; \*FOO } );
	return $refs[ rand( @refs ) ];
}

t/base.t  view on Meta::CPAN

is( __PACKAGE__->can( 'new' ), \&UNIVERSAL::new, 'new() should be UNIVERSAL' );

sub Foo::new {}

sub Foo::Bar::new {}

sub Foo::Bar::Baz::new {}

my @classes  = qw( Foo Foo::Bar Foo::Bar::Baz Test::Builder );
my @reftypes = qw( HASH SCALAR ARRAY GLOB );
my %objects  = map { $_ => [] } @classes;
my %reftypes = map { $_ => [] } @reftypes;

for ( 1 .. 100 )
{
	my $object = UNIVERSAL::new();
	push @{ $objects{  ref      $object   } }, $object;
	push @{ $reftypes{ reftype( $object ) } }, $object;
}

my $obj_total;



( run in 0.353 second using v1.01-cache-2.11-cpan-65fba6d93b7 )