From: Jesse Luehrs Date: Wed, 20 Apr 2011 15:34:04 +0000 (-0500) Subject: tests X-Git-Tag: 2.0001~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c0c1cd86fadff4d6c3b060b6fd951bb31e438236;p=gitmo%2FMoose.git tests --- diff --git a/t/cmop/anon_packages.t b/t/cmop/anon_packages.t new file mode 100644 index 0000000..8c9053d --- /dev/null +++ b/t/cmop/anon_packages.t @@ -0,0 +1,41 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Fatal; + +use Class::MOP; + +{ + my $name; + { + my $anon = Class::MOP::Package->create_anon; + $name = $anon->name; + $anon->add_package_symbol('&foo' => sub {}); + can_ok($name, 'foo'); + ok($anon->is_anon, "is anon"); + } + + ok(!$name->can('foo'), "!$name->can('foo')"); +} + +{ + my $name; + { + my $anon = Class::MOP::Package->create_anon(weaken => 0); + $name = $anon->name; + $anon->add_package_symbol('&foo' => sub {}); + can_ok($name, 'foo'); + ok($anon->is_anon, "is anon"); + } + + can_ok($name, 'foo'); +} + +{ + like(exception { Class::MOP::Package->create_anon(cache => 1) }, + qr/^Packages are not cacheable/, + "can't cache anon packages"); +} + +done_testing;