504f7750ed0e95847b9bfcdc9985bcd72be189ef
[gitmo/Moose.git] / t / metaclasses / exporter_meta_lookup.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 use Test::Fatal;
8
9 {
10     package Class::Vacuum::Innards;
11     use Moose;
12
13     package Class::Vacuum;
14     use Moose ();
15     use Moose::Exporter;
16
17     BEGIN {
18         Moose::Exporter->setup_import_methods(
19             also        => 'Moose',
20             meta_lookup => sub { Class::MOP::class_of('Class::Vacuum::Innards') },
21         );
22     }
23 }
24
25 {
26     package Victim;
27     BEGIN { Class::Vacuum->import };
28
29     has star_rod => (
30         is => 'ro',
31     );
32 }
33
34 ok(Class::Vacuum::Innards->can('star_rod'), 'Vacuum stole the star_rod method');
35 ok(!Victim->can('star_rod'), 'Victim does not get it at all');
36
37 done_testing;
38