use warnings;
use Test::More;
-use Test::Exception;
-BEGIN {
- eval "use Test::Output;";
- plan skip_all => "Test::Output is required for this test" if $@;
-}
+use Test::Fatal;
+use Test::Requires {
+ 'Test::Output' => '0.01', # skip all if not installed
+};
{
package HasOwnImmutable;
use Moose ();
- ::dies_ok(
- sub {
- Moose::Exporter->setup_import_methods(
+ ::like(
+ ::exception{ Moose::Exporter->setup_import_methods(
also => [ 'Moose', 'MooseX::CircularAlso' ],
);
- },
- 'a circular reference in also dies with an error'
- );
-
- ::like(
- $@,
+ },
qr/\QCircular reference in 'also' parameter to Moose::Exporter between MooseX::CircularAlso and MooseX::CircularAlso/,
- 'got the expected error from circular reference in also'
+ 'a circular reference in also dies with an error'
);
}
use Moose ();
- ::dies_ok(
- sub {
- Moose::Exporter->setup_import_methods(
- also => [ 'NoSuchThing' ],
- );
- },
- 'a package which does not use Moose::Exporter in also dies with an error'
- );
-
::like(
- $@,
+ ::exception{ Moose::Exporter->setup_import_methods(
+ also => ['NoSuchThing'],
+ );
+ },
qr/\QPackage in also (NoSuchThing) does not seem to use Moose::Exporter (is it loaded?) at /,
- 'got the expected error from a reference in also to a package which is not loaded'
+ 'a package which does not use Moose::Exporter in also dies with an error'
);
}
use Moose ();
- ::dies_ok(
- sub {
- Moose::Exporter->setup_import_methods(
- also => [ 'Moose::Meta::Method' ],
- );
- },
- 'a package which does not use Moose::Exporter in also dies with an error'
- );
-
::like(
- $@,
+ ::exception{ Moose::Exporter->setup_import_methods(
+ also => ['Moose::Meta::Method'],
+ );
+ },
qr/\QPackage in also (Moose::Meta::Method) does not seem to use Moose::Exporter at /,
- 'got the expected error from a reference in also to a package which does not use Moose::Exporter'
+ 'a package which does not use Moose::Exporter in also dies with an error'
);
}