tests
Jesse Luehrs [Wed, 20 Apr 2011 15:34:04 +0000 (10:34 -0500)]
t/cmop/anon_packages.t [new file with mode: 0644]

diff --git a/t/cmop/anon_packages.t b/t/cmop/anon_packages.t
new file mode 100644 (file)
index 0000000..8c9053d
--- /dev/null
@@ -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;