#!/usr/bin/perl use strict; use warnings; use Test::More no_plan => 1; BEGIN { use_ok('MooseX::Exporter'); } { # define the sugar ... package Foo::Sugar; use Moose::Role; sub foo { my $pkg = shift; return sub { "Foo::Sugar::foo exported from $pkg" } } } { # create the package which exports the sugar ... package Foo; use metaclass; use MooseX::Exporter 'Foo::Sugar'; } Foo->import(); is(foo(), 'Foo::Sugar::foo exported from Foo', '... got the result we expected');