one more Eval::Closure use
[gitmo/Moose.git] / t / type_constraints / util_std_type_constraints.t
index 0aaf02c..12ca75a 100644 (file)
@@ -5,6 +5,7 @@ use warnings;
 
 use Test::More;
 
+use Eval::Closure;
 use IO::File;
 use Moose::Util::TypeConstraints;
 use Scalar::Util qw( blessed openhandle );
@@ -731,9 +732,9 @@ for my $name ( sort keys %tests ) {
 
     my $inlined;
     {
-        local $@;
-        $inlined = eval 'sub { ( ' . $type->_inline_check('$_[0]') . ' ) }';
-        die $@ if $@;
+        $inlined = eval_closure(
+            source => 'sub { ( ' . $type->_inline_check('$_[0]') . ' ) }',
+        );
     }
 
     ok(
@@ -1011,9 +1012,10 @@ sub test_constraint {
 
     my $inlined;
     if ( $type->has_inlined_type_constraint ) {
-        local $@;
-        $inlined = eval 'sub { ( ' . $type->_inline_check('$_[0]') . ' ) }';
-        die $@ if $@;
+        $inlined = eval_closure(
+            source      => 'sub { ( ' . $type->_inline_check('$_[0]') . ' ) }',
+            environment => $type->inline_environment,
+        );
     }
 
     for my $accept ( @{ $tests->{accept} || [] } ) {