summaryrefslogtreecommitdiff
path: root/t/metaclasses/exporter_meta_lookup.t
diff options
context:
space:
mode:
Diffstat (limited to 't/metaclasses/exporter_meta_lookup.t')
-rw-r--r--t/metaclasses/exporter_meta_lookup.t62
1 files changed, 62 insertions, 0 deletions
diff --git a/t/metaclasses/exporter_meta_lookup.t b/t/metaclasses/exporter_meta_lookup.t
new file mode 100644
index 0000000..629b48b
--- /dev/null
+++ b/t/metaclasses/exporter_meta_lookup.t
@@ -0,0 +1,62 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+{
+ package Class::Vacuum::Innards;
+ use Moose;
+
+ package Class::Vacuum;
+ use Moose ();
+ use Moose::Exporter;
+
+ sub meta_lookup { $_[0] }
+
+ BEGIN {
+ Moose::Exporter->setup_import_methods(
+ also => 'Moose',
+ meta_lookup => sub { Class::MOP::class_of('Class::Vacuum::Innards') },
+ with_meta => ['meta_lookup'],
+ );
+ }
+}
+
+{
+ package Victim;
+ BEGIN { Class::Vacuum->import };
+
+ has star_rod => (
+ is => 'ro',
+ );
+
+ ::is(meta_lookup, Class::Vacuum::Innards->meta, "right meta_lookup");
+}
+
+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');
+
+{
+ package Class::Vacuum::Reexport;
+ use Moose::Exporter;
+
+ BEGIN {
+ Moose::Exporter->setup_import_methods(also => 'Class::Vacuum');
+ }
+}
+
+{
+ package Victim2;
+ BEGIN { Class::Vacuum::Reexport->import }
+
+ has parasol => (
+ is => 'ro',
+ );
+
+ ::is(meta_lookup, Class::Vacuum::Innards->meta, "right meta_lookup");
+}
+
+ok(Class::Vacuum::Innards->can('parasol'), 'Vacuum stole the parasol method');
+ok(!Victim2->can('parasol'), 'Victim does not get it at all');
+
+done_testing;