use strict;
use warnings;
-use Test::More tests => 9;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
-BEGIN {
- use_ok('Moose');
- use_ok('Moose::Util::TypeConstraints');
-}
+use Moose::Util::TypeConstraints;
=pod
-This tests demonstrates that Moose will not override
-a pre-existing type constraint of the same name when
+This tests demonstrates that Moose will not override
+a preexisting type constraint of the same name when
making constraints for a Moose-class.
It also tests that an attribute which uses a 'Foo' for
-it's isa option will get the subtype Foo, and not a
+it's isa option will get the subtype Foo, and not a
type representing the Foo moose class.
=cut
-BEGIN {
+BEGIN {
# create this subtype first (in BEGIN)
- subtype Foo
- => as 'Value'
+ subtype Foo
+ => as 'Value'
=> where { $_ eq 'Foo' };
}
{
package Bar;
use Moose;
-
+
has 'foo' => (is => 'rw', isa => 'Foo');
}
my $bar = Bar->new;
isa_ok($bar, 'Bar');
-lives_ok {
- $bar->foo('Foo');
-} '... checked the type constraint correctly';
-
-dies_ok {
- $bar->foo(Foo->new);
-} '... checked the type constraint correctly';
-
+is( exception {
+ $bar->foo('Foo');
+}, undef, '... checked the type constraint correctly' );
+isnt( exception {
+ $bar->foo(Foo->new);
+}, undef, '... checked the type constraint correctly' );
+done_testing;