use Test::Exception;
BEGIN {
- unless ( eval 'use Test::Warn; 1' ) {
- plan skip_all => 'These tests require Test::Warn';
+ unless ( eval 'use Test::Warn 0.11; 1' ) {
+ plan skip_all => 'These tests require Test::Warn 0.11';
}
else {
- plan tests => 40;
+ plan tests => 45;
}
}
::like(
$@,
- qr/\QCircular reference in also parameter to MooseX::Exporter between MooseX::CircularAlso and MooseX::CircularAlso/,
+ qr/\QCircular reference in also parameter to Moose::Exporter between MooseX::CircularAlso and MooseX::CircularAlso/,
'got the expected error from circular reference in also'
);
}
::like(
$@,
- qr/\QPackage in also (NoSuchThing) does not seem to use MooseX::Exporter/,
+ qr/\QPackage in also (NoSuchThing) does not seem to use Moose::Exporter/,
'got the expected error from a reference in also to a package which does not use Moose::Exporter'
);
}
+
+{
+ package MooseX::OverridingSugar;
+
+ use Moose ();
+
+ sub has {
+ my $caller = shift;
+ return $caller . ' called has';
+ }
+
+ Moose::Exporter->setup_import_methods(
+ with_caller => ['has'],
+ also => 'Moose',
+ );
+}
+
+{
+ package WantsOverridingSugar;
+
+ MooseX::OverridingSugar->import();
+
+ ::can_ok( 'WantsOverridingSugar', 'has' );
+ ::can_ok( 'WantsOverridingSugar', 'with' );
+ ::is( has('foo'), 'WantsOverridingSugar called has',
+ 'has from MooseX::OverridingSugar is called, not has from Moose' );
+
+ MooseX::OverridingSugar->unimport();
+}
+
+{
+ ok( ! WantsSugar->can('has'), 'WantsSugar::has() has been cleaned' );
+ ok( ! WantsSugar->can('with'), 'WantsSugar::with() has been cleaned' );
+}
+