my $import = $class->_make_import_sub( $exporter, \@exports_from );
- my $unimport = $class->_make_unimport_sub( [ keys %{$exports} ] );
+ my $unimport = $class->_make_unimport_sub( \@exports_from, [ keys %{$exports} ] );
no strict 'refs';
*{ $exporting_package . '::import' } = $import;
}
sub _make_unimport_sub {
- my $class = shift;
- my $exported = shift;
+ shift;
+ my $sources = shift;
+ my $keywords = shift;
return sub {
+ my $class = shift;
my $caller = scalar caller();
- Moose::Exporter->_remove_keywords( $caller, $exported );
+ Moose::Exporter->_remove_keywords(
+ $caller,
+ [ $class, @{$sources} ],
+ $keywords
+ );
};
}
sub _remove_keywords {
shift;
my $package = shift;
+ my $sources = shift;
my $keywords = shift;
+ my %sources = map { $_ => 1 } @{$sources};
+
no strict 'refs';
# loop through the keywords ...
# make sure it is from us
my ($pkg_name) = Class::MOP::get_code_info($keyword);
- next if $pkg_name eq $package;
+ next unless $sources{$pkg_name};
# and if it is from us, then undef the slot
delete ${ $package . '::' }{$name};
use strict;
use warnings;
-use Test::More tests => 38;
+use Test::More;
use Test::Exception;
+BEGIN {
+ unless ( eval 'use Test::Warn; 1' ) {
+ plan skip_all => 'These tests require Test::Warn';
+ }
+ else {
+ plan tests => 40;
+ }
+}
+
+
+{
+ package HasOwnImmutable;
+
+ use Moose;
+
+ no Moose;
+
+ ::warning_is( sub { eval q[sub make_immutable { return 'foo' }] },
+ '',
+ 'no warning when defining our own make_immutable sub' );
+}
+
+{
+ is( HasOwnImmutable->make_immutable(), 'foo',
+ 'HasOwnImmutable->make_immutable does not get overwritten' );
+}
{
package MooseX::Empty;