use lib 't/lib', 'lib';
use Test::More;
-use Test::Exception;
+use Test::Fatal;
{
package My::SimpleTrait;
{
require Moose::Util::TypeConstraints;
- dies_ok { Moose::Util::TypeConstraints->import( -traits => 'My::SimpleTrait' ) }
- 'cannot provide -traits to an exporting module that does not init_meta';
- like( $@, qr/does not have an init_meta/,
- '... and error provides a useful explanation' );
+ like(
+ exception {
+ Moose::Util::TypeConstraints->import(
+ -traits => 'My::SimpleTrait' );
+ },
+ qr/does not have an init_meta/,
+ 'cannot provide -traits to an exporting module that does not init_meta'
+ );
}
{
has an_attr => ( is => 'ro' );
}
-lives_ok {
+is( exception {
my $instance = Class::WithAlreadyPresentTrait->new( an_attr => 'value' );
is( $instance->an_attr, 'value', 'Can get value' );
-}
-'Can create instance and access attributes';
+}, undef, 'Can create instance and access attributes' );
{
has an_attr => ( is => 'ro' );
}
-lives_ok {
+is( exception {
my $instance = Class::WhichLoadsATraitFromDisk->new( an_attr => 'value' );
is( $instance->an_attr, 'value', 'Can get value' );
-}
-'Can create instance and access attributes';
+}, undef, 'Can create instance and access attributes' );
done_testing;