From: Yuval Kogman Date: Thu, 1 Oct 2009 02:52:10 +0000 (+0200) Subject: allow exporting to main X-Git-Tag: 0.93~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d573315486384a8f04622c708e8c9b63d181ff81;p=gitmo%2FMoose.git allow exporting to main --- diff --git a/lib/Moose/Exporter.pm b/lib/Moose/Exporter.pm index 0e07062..b2e04e6 100644 --- a/lib/Moose/Exporter.pm +++ b/lib/Moose/Exporter.pm @@ -301,7 +301,6 @@ sub _make_import_sub { my $exporting_package = shift; my $exporter = shift; my $exports_from = shift; - my $export_to_main = shift; return sub { @@ -338,13 +337,6 @@ sub _make_import_sub { strict->import; warnings->import; - # we should never export to main - if ( $CALLER eq 'main' && !$export_to_main ) { - warn - qq{$class does not export its sugar to the 'main' package.\n}; - return; - } - my $did_init_meta; for my $c ( grep { $_->can('init_meta') } $class, @{$exports_from} ) { # init_meta can apply a role, which when loaded uses diff --git a/t/010_basics/016_load_into_main.t b/t/010_basics/016_load_into_main.t index fde43f0..b0036b8 100644 --- a/t/010_basics/016_load_into_main.t +++ b/t/010_basics/016_load_into_main.t @@ -3,17 +3,15 @@ use strict; use warnings; -use Test::More; -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; - plan tests => 2; -} +use Test::More tests => 4; +use Test::Exception; -stderr_like( sub { package main; eval 'use Moose' }, - qr/\QMoose does not export its sugar to the 'main' package/, - 'Moose warns when loaded from the main package' ); +lives_ok { + eval 'use Moose'; +} "export to main"; + +isa_ok( main->meta, "Moose::Meta::Class" ); + +isa_ok( main->new, "main"); +isa_ok( main->new, "Moose::Object" ); -stderr_like( sub { package main; eval 'use Moose::Role' }, - qr/\QMoose::Role does not export its sugar to the 'main' package/, - 'Moose::Role warns when loaded from the main package' );