Basic test for meta_lookup
Shawn M Moore [Mon, 22 Aug 2011 20:19:52 +0000 (16:19 -0400)]
t/metaclasses/exporter_meta_lookup.t [new file with mode: 0644]

diff --git a/t/metaclasses/exporter_meta_lookup.t b/t/metaclasses/exporter_meta_lookup.t
new file mode 100644 (file)
index 0000000..504f775
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Fatal;
+
+{
+    package Class::Vacuum::Innards;
+    use Moose;
+
+    package Class::Vacuum;
+    use Moose ();
+    use Moose::Exporter;
+
+    BEGIN {
+        Moose::Exporter->setup_import_methods(
+            also        => 'Moose',
+            meta_lookup => sub { Class::MOP::class_of('Class::Vacuum::Innards') },
+        );
+    }
+}
+
+{
+    package Victim;
+    BEGIN { Class::Vacuum->import };
+
+    has star_rod => (
+        is => 'ro',
+    );
+}
+
+ok(Class::Vacuum::Innards->can('star_rod'), 'Vacuum stole the star_rod method');
+ok(!Victim->can('star_rod'), 'Victim does not get it at all');
+
+done_testing;
+