use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
use Moose::Util::TypeConstraints;
use Moose::Meta::TypeConstraint;
);
}
-throws_ok {
+like( exception {
Quux->new(age => 3)
-} qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' with value 3 \(not isa Positive\)/;
+}, qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' with value 3 \(not isa Positive\)/ );
-lives_ok {
+is( exception {
Quux->new(age => (bless {}, 'Positive'));
-};
+}, undef );
eval "
package Positive;
use Moose;
";
-throws_ok {
+like( exception {
Quux->new(age => 3)
-} qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' with value 3 \(not isa Positive\)/;
+}, qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' with value 3 \(not isa Positive\)/ );
-lives_ok {
+is( exception {
Quux->new(age => Positive->new)
-};
+}, undef );
class_type 'Negative' => message { "$_ is not a Negative Nancy" };
);
}
-throws_ok {
+like( exception {
Quux::Ier->new(age => 3)
-} qr/^Attribute \(age\) does not pass the type constraint because: 3 is not a Negative Nancy /;
+}, qr/^Attribute \(age\) does not pass the type constraint because: 3 is not a Negative Nancy / );
-lives_ok {
+is( exception {
Quux::Ier->new(age => (bless {}, 'Negative'))
-};
+}, undef );
done_testing;