Redid conversion to Test::Fatal
[gitmo/Moose.git] / t / 070_native_traits / 010_trait_array.t
index c88fd6e..3785904 100644 (file)
@@ -6,11 +6,10 @@ use warnings;
 use lib 't/lib';
 
 use Moose ();
-use Moose::Util::MetaRole;
 use Moose::Util::TypeConstraints;
 use NoInlineAttribute;
 use Test::More;
-use Test::Exception;
+use Test::Fatal;
 use Test::Moose;
 
 {
@@ -138,28 +137,23 @@ sub run_tests {
         ok( !$obj->is_empty, 'values is not empty' );
         is( $obj->count, 3, 'count returns 3' );
 
-        throws_ok { $obj->count(22) }
-        qr/Cannot call count with any arguments/,
-            'throws an error when passing an argument passed to count';
+        like( exception { $obj->count(22) }, qr/Cannot call count with any arguments/, 'throws an error when passing an argument passed to count' );
 
-        lives_ok { $obj->push( 1, 2, 3 ) }
-        'pushed three new values and lived';
+        is( exception { $obj->push( 1, 2, 3 ) }, undef, 'pushed three new values and lived' );
 
-        lives_ok { $obj->push() } 'call to push without arguments lives';
+        is( exception { $obj->push() }, undef, 'call to push without arguments lives' );
 
-        lives_and {
+        is( exception {
             is( $obj->unshift( 101, 22 ), 8,
                 'unshift returns size of the new array' );
-        }
-        'unshifted two values and lived';
+        }, undef, 'unshifted two values and lived' );
 
         is_deeply(
             $obj->_values, [ 101, 22, 10, 12, 42, 1, 2, 3 ],
             'unshift changed the value of the array in the object'
         );
 
-        lives_ok { $obj->unshift() }
-        'call to unshift without arguments lives';
+        is( exception { $obj->unshift() }, undef, 'call to unshift without arguments lives' );
 
         is( $obj->pop, 3, 'pop returns the last value in the array' );
 
@@ -168,15 +162,11 @@ sub run_tests {
             'pop changed the value of the array in the object'
         );
 
-        throws_ok { $obj->pop(42) }
-        qr/Cannot call pop with any arguments/,
-            'call to pop with arguments dies';
+        like( exception { $obj->pop(42) }, qr/Cannot call pop with any arguments/, 'call to pop with arguments dies' );
 
         is( $obj->shift, 101, 'shift returns the first value' );
 
-        throws_ok { $obj->shift(42) }
-        qr/Cannot call shift with any arguments/,
-            'call to shift with arguments dies';
+        like( exception { $obj->shift(42) }, qr/Cannot call shift with any arguments/, 'call to shift with arguments dies' );
 
         is_deeply(
             $obj->_values, [ 22, 10, 12, 42, 1, 2 ],
@@ -188,9 +178,7 @@ sub run_tests {
             'call to elements returns values as a list'
         );
 
-        throws_ok { $obj->elements(22) }
-        qr/Cannot call elements with any arguments/,
-            'throws an error when passing an argument passed to elements';
+        like( exception { $obj->elements(22) }, qr/Cannot call elements with any arguments/, 'throws an error when passing an argument passed to elements' );
 
         $obj->_values( [ 1, 2, 3 ] );
 
@@ -199,120 +187,90 @@ sub run_tests {
         is( $obj->get(2),      3, 'get values at index 2' );
         is( $obj->get_curried, 2, 'get_curried returns value at index 1' );
 
-        throws_ok { $obj->get() }
-        qr/Cannot call get without at least 1 argument/,
-            'throws an error when get is called without any arguments';
+        like( exception { $obj->get() }, qr/Cannot call get without at least 1 argument/, 'throws an error when get is called without any arguments' );
 
-        throws_ok { $obj->get( {} ) }
-        qr/The index passed to get must be an integer/,
-            'throws an error when get is called with an invalid argument';
+        like( exception { $obj->get( {} ) }, qr/The index passed to get must be an integer/, 'throws an error when get is called with an invalid argument' );
 
-        throws_ok { $obj->get(2.2) }
-        qr/The index passed to get must be an integer/,
-            'throws an error when get is called with an invalid argument';
+        like( exception { $obj->get(2.2) }, qr/The index passed to get must be an integer/, 'throws an error when get is called with an invalid argument' );
 
-        throws_ok { $obj->get('foo') }
-        qr/The index passed to get must be an integer/,
-            'throws an error when get is called with an invalid argument';
+        like( exception { $obj->get('foo') }, qr/The index passed to get must be an integer/, 'throws an error when get is called with an invalid argument' );
 
-        throws_ok { $obj->get_curried(2) }
-        qr/Cannot call get with more than 1 argument/,
-            'throws an error when get_curried is called with an argument';
+        like( exception { $obj->get_curried(2) }, qr/Cannot call get with more than 1 argument/, 'throws an error when get_curried is called with an argument' );
 
-        lives_and {
+        is( exception {
             is( $obj->set( 1, 100 ), 100, 'set returns new value' );
-        }
-        'set value at index 1 lives';
+        }, undef, 'set value at index 1 lives' );
 
         is( $obj->get(1), 100, 'get value at index 1 returns new value' );
 
 
-        throws_ok { $obj->set( 1, 99, 42 ) }
-        qr/Cannot call set with more than 2 arguments/,
-            'throws an error when set is called with three arguments';
+        like( exception { $obj->set( 1, 99, 42 ) }, qr/Cannot call set with more than 2 arguments/, 'throws an error when set is called with three arguments' );
 
-        lives_ok { $obj->set_curried_1(99) } 'set_curried_1 lives';
+        is( exception { $obj->set_curried_1(99) }, undef, 'set_curried_1 lives' );
 
         is( $obj->get(1), 99, 'get value at index 1 returns new value' );
 
-        throws_ok { $obj->set_curried_1( 99, 42 ) }
-        qr/Cannot call set with more than 2 arguments/,
-            'throws an error when set_curried_1 is called with two arguments';
+        like( exception { $obj->set_curried_1( 99, 42 ) }, qr/Cannot call set with more than 2 arguments/, 'throws an error when set_curried_1 is called with two arguments' );
 
-        lives_ok { $obj->set_curried_2 } 'set_curried_2 lives';
+        is( exception { $obj->set_curried_2 }, undef, 'set_curried_2 lives' );
 
         is( $obj->get(1), 98, 'get value at index 1 returns new value' );
 
-        throws_ok { $obj->set_curried_2(42) }
-        qr/Cannot call set with more than 2 arguments/,
-            'throws an error when set_curried_2 is called with one argument';
+        like( exception { $obj->set_curried_2(42) }, qr/Cannot call set with more than 2 arguments/, 'throws an error when set_curried_2 is called with one argument' );
 
         is(
             $obj->accessor(1), 98,
             'accessor with one argument returns value at index 1'
         );
 
-        lives_and {
+        is( exception {
             is( $obj->accessor( 1 => 97 ), 97, 'accessor returns new value' );
-        }
-        'accessor as writer lives';
+        }, undef, 'accessor as writer lives' );
 
         is(
             $obj->get(1), 97,
             'accessor set value at index 1'
         );
 
-        throws_ok { $obj->accessor( 1, 96, 42 ) }
-        qr/Cannot call accessor with more than 2 arguments/,
-            'throws an error when accessor is called with three arguments';
+        like( exception { $obj->accessor( 1, 96, 42 ) }, qr/Cannot call accessor with more than 2 arguments/, 'throws an error when accessor is called with three arguments' );
 
         is(
             $obj->accessor_curried_1, 97,
             'accessor_curried_1 returns expected value when called with no arguments'
         );
 
-        lives_ok { $obj->accessor_curried_1(95) }
-        'accessor_curried_1 as writer lives';
+        is( exception { $obj->accessor_curried_1(95) }, undef, 'accessor_curried_1 as writer lives' );
 
         is(
             $obj->get(1), 95,
             'accessor_curried_1 set value at index 1'
         );
 
-        throws_ok { $obj->accessor_curried_1( 96, 42 ) }
-        qr/Cannot call accessor with more than 2 arguments/,
-            'throws an error when accessor_curried_1 is called with two arguments';
+        like( exception { $obj->accessor_curried_1( 96, 42 ) }, qr/Cannot call accessor with more than 2 arguments/, 'throws an error when accessor_curried_1 is called with two arguments' );
 
-        lives_ok { $obj->accessor_curried_2 }
-        'accessor_curried_2 as writer lives';
+        is( exception { $obj->accessor_curried_2 }, undef, 'accessor_curried_2 as writer lives' );
 
         is(
             $obj->get(1), 90,
             'accessor_curried_2 set value at index 1'
         );
 
-        throws_ok { $obj->accessor_curried_2(42) }
-        qr/Cannot call accessor with more than 2 arguments/,
-            'throws an error when accessor_curried_2 is called with one argument';
+        like( exception { $obj->accessor_curried_2(42) }, qr/Cannot call accessor with more than 2 arguments/, 'throws an error when accessor_curried_2 is called with one argument' );
 
-        lives_ok { $obj->clear } 'clear lives';
+        is( exception { $obj->clear }, undef, 'clear lives' );
 
         ok( $obj->is_empty, 'values is empty after call to clear' );
 
         $obj->set( 0 => 42 );
 
-        throws_ok { $obj->clear(50) }
-        qr/Cannot call clear with any arguments/,
-            'throws an error when clear is called with an argument';
+        like( exception { $obj->clear(50) }, qr/Cannot call clear with any arguments/, 'throws an error when clear is called with an argument' );
 
         ok(
             !$obj->is_empty,
             'values is not empty after failed call to clear'
         );
 
-        throws_ok { $obj->is_empty(50) }
-        qr/Cannot call is_empty with any arguments/,
-            'throws an error when is_empty is called with an argument';
+        like( exception { $obj->is_empty(50) }, qr/Cannot call is_empty with any arguments/, 'throws an error when is_empty is called with an argument' );
 
         $obj->clear;
         is(
@@ -320,94 +278,80 @@ sub run_tests {
             'pushed 4 elements, got number of elements in the array back'
         );
 
-        lives_and {
+        is( exception {
             is( $obj->delete(2), 10, 'delete returns deleted value' );
-        }
-        'delete lives';
+        }, undef, 'delete lives' );
 
         is_deeply(
             $obj->_values, [ 1, 5, 42 ],
             'delete removed the specified element'
         );
 
-        throws_ok { $obj->delete( 2, 3 ) }
-        qr/Cannot call delete with more than 1 argument/,
-            'throws an error when delete is called with two arguments';
+        like( exception { $obj->delete( 2, 3 ) }, qr/Cannot call delete with more than 1 argument/, 'throws an error when delete is called with two arguments' );
 
-        lives_ok { $obj->delete_curried } 'delete_curried lives';
+        is( exception { $obj->delete_curried }, undef, 'delete_curried lives' );
 
         is_deeply(
             $obj->_values, [ 1, 42 ],
             'delete removed the specified element'
         );
 
-        throws_ok { $obj->delete_curried(2) }
-        qr/Cannot call delete with more than 1 argument/,
-            'throws an error when delete_curried is called with one argument';
+        like( exception { $obj->delete_curried(2) }, qr/Cannot call delete with more than 1 argument/, 'throws an error when delete_curried is called with one argument' );
 
-        lives_ok { $obj->insert( 1, 21 ) } 'insert lives';
+        is( exception { $obj->insert( 1, 21 ) }, undef, 'insert lives' );
 
         is_deeply(
             $obj->_values, [ 1, 21, 42 ],
             'insert added the specified element'
         );
 
-        throws_ok { $obj->insert( 1, 22, 44 ) }
-        qr/Cannot call insert with more than 2 arguments/,
-            'throws an error when insert is called with three arguments';
+        like( exception { $obj->insert( 1, 22, 44 ) }, qr/Cannot call insert with more than 2 arguments/, 'throws an error when insert is called with three arguments' );
 
-        lives_and {
+        is( exception {
             is_deeply(
                 [ $obj->splice( 1, 0, 2, 3 ) ],
                 [],
                 'return value of splice is empty list when not removing elements'
             );
-        }
-        'splice lives';
+        }, undef, 'splice lives' );
 
         is_deeply(
             $obj->_values, [ 1, 2, 3, 21, 42 ],
             'splice added the specified elements'
         );
 
-        lives_and {
+        is( exception {
             is_deeply(
                 [ $obj->splice( 1, 2, 99 ) ],
                 [ 2, 3 ],
                 'splice returns list of removed values'
             );
-        }
-        'splice lives';
+        }, undef, 'splice lives' );
 
         is_deeply(
             $obj->_values, [ 1, 99, 21, 42 ],
             'splice added the specified elements'
         );
 
-        throws_ok { $obj->splice() }
-        qr/Cannot call splice without at least 1 argument/,
-            'throws an error when splice is called with no arguments';
+        like( exception { $obj->splice() }, qr/Cannot call splice without at least 1 argument/, 'throws an error when splice is called with no arguments' );
 
-        throws_ok { $obj->splice( 1, 'foo', ) }
-        qr/The length argument passed to splice must be an integer/,
-            'throws an error when splice is called with an invalid length';
+        like( exception { $obj->splice( 1, 'foo', ) }, qr/The length argument passed to splice must be an integer/, 'throws an error when splice is called with an invalid length' );
 
-        lives_ok { $obj->splice_curried_1( 2, 101 ) }
-        'splice_curried_1 lives';
+        is( exception { $obj->splice_curried_1( 2, 101 ) }, undef, 'splice_curried_1 lives' );
 
         is_deeply(
             $obj->_values, [ 1, 101, 42 ],
             'splice added the specified elements'
         );
 
-        lives_ok { $obj->splice_curried_2(102) } 'splice_curried_2 lives';
+        is( exception { $obj->splice_curried_2(102) }, undef, 'splice_curried_2 lives' );
 
         is_deeply(
             $obj->_values, [ 1, 102 ],
             'splice added the specified elements'
         );
 
-        lives_ok { $obj->splice_curried_all } 'splice_curried_all lives';
+        is( exception { $obj->splice_curried_all }, undef, 'splice_curried_all lives' );
 
         is_deeply(
             $obj->_values, [ 1, 3, 4, 5 ],
@@ -438,15 +382,11 @@ sub run_tests {
             'sort returns values sorted by provided function'
         );
 
-        throws_ok { $obj->sort(1) }
-        qr/The argument passed to sort must be a code reference/,
-            'throws an error when passing a non coderef to sort';
+        like( exception { $obj->sort(1) }, qr/The argument passed to sort must be a code reference/, 'throws an error when passing a non coderef to sort' );
 
-        throws_ok {
+        like( exception {
             $obj->sort( sub { }, 27 );
-        }
-        qr/Cannot call sort with more than 1 argument/,
-            'throws an error when passing two arguments to sort';
+        }, qr/Cannot call sort with more than 1 argument/, 'throws an error when passing two arguments to sort' );
 
         $obj->_values( [ 3, 9, 5, 22, 11 ] );
 
@@ -464,17 +404,13 @@ sub run_tests {
             'sort_in_place with function sorts values'
         );
 
-        throws_ok {
+        like( exception {
             $obj->sort_in_place( 27 );
-        }
-        qr/The argument passed to sort_in_place must be a code reference/,
-            'throws an error when passing a non coderef to sort_in_place';
+        }, qr/The argument passed to sort_in_place must be a code reference/, 'throws an error when passing a non coderef to sort_in_place' );
 
-        throws_ok {
+        like( exception {
             $obj->sort_in_place( sub { }, 27 );
-        }
-        qr/Cannot call sort_in_place with more than 1 argument/,
-            'throws an error when passing two arguments to sort_in_place';
+        }, qr/Cannot call sort_in_place with more than 1 argument/, 'throws an error when passing two arguments to sort_in_place' );
 
         $obj->_values( [ 3, 9, 5, 22, 11 ] );
 
@@ -485,9 +421,7 @@ sub run_tests {
             'sort_in_place_curried sorts values'
         );
 
-        throws_ok { $obj->sort_in_place_curried(27) }
-        qr/Cannot call sort_in_place with more than 1 argument/,
-            'throws an error when passing one argument passed to sort_in_place_curried';
+        like( exception { $obj->sort_in_place_curried(27) }, qr/Cannot call sort_in_place with more than 1 argument/, 'throws an error when passing one argument passed to sort_in_place_curried' );
 
         $obj->_values( [ 1 .. 5 ] );
 
@@ -497,19 +431,13 @@ sub run_tests {
             'map returns the expected values'
         );
 
-        throws_ok { $obj->map }
-        qr/Cannot call map without at least 1 argument/,
-            'throws an error when passing no arguments to map';
+        like( exception { $obj->map }, qr/Cannot call map without at least 1 argument/, 'throws an error when passing no arguments to map' );
 
-        throws_ok {
+        like( exception {
             $obj->map( sub { }, 2 );
-        }
-        qr/Cannot call map with more than 1 argument/,
-            'throws an error when passing two arguments to map';
+        }, qr/Cannot call map with more than 1 argument/, 'throws an error when passing two arguments to map' );
 
-        throws_ok { $obj->map( {} ) }
-        qr/The argument passed to map must be a code reference/,
-            'throws an error when passing a non coderef to map';
+        like( exception { $obj->map( {} ) }, qr/The argument passed to map must be a code reference/, 'throws an error when passing a non coderef to map' );
 
         $obj->_values( [ 1 .. 5 ] );
 
@@ -519,11 +447,9 @@ sub run_tests {
             'map_curried returns the expected values'
         );
 
-        throws_ok {
+        like( exception {
             $obj->map_curried( sub { } );
-        }
-        qr/Cannot call map with more than 1 argument/,
-            'throws an error when passing one argument passed to map_curried';
+        }, qr/Cannot call map with more than 1 argument/, 'throws an error when passing one argument passed to map_curried' );
 
         $obj->_values( [ 2 .. 9 ] );
 
@@ -533,19 +459,13 @@ sub run_tests {
             'grep returns the expected values'
         );
 
-        throws_ok { $obj->grep }
-        qr/Cannot call grep without at least 1 argument/,
-            'throws an error when passing no arguments to grep';
+        like( exception { $obj->grep }, qr/Cannot call grep without at least 1 argument/, 'throws an error when passing no arguments to grep' );
 
-        throws_ok {
+        like( exception {
             $obj->grep( sub { }, 2 );
-        }
-        qr/Cannot call grep with more than 1 argument/,
-            'throws an error when passing two arguments to grep';
+        }, qr/Cannot call grep with more than 1 argument/, 'throws an error when passing two arguments to grep' );
 
-        throws_ok { $obj->grep( {} ) }
-        qr/The argument passed to grep must be a code reference/,
-            'throws an error when passing a non coderef to grep';
+        like( exception { $obj->grep( {} ) }, qr/The argument passed to grep must be a code reference/, 'throws an error when passing a non coderef to grep' );
 
         my $overloader = Overloader->new( sub { $_ < 5 } );
         is_deeply(
@@ -560,11 +480,9 @@ sub run_tests {
             'grep_curried returns the expected values'
         );
 
-        throws_ok {
+        like( exception {
             $obj->grep_curried( sub { } );
-        }
-        qr/Cannot call grep with more than 1 argument/,
-            'throws an error when passing one argument passed to grep_curried';
+        }, qr/Cannot call grep with more than 1 argument/, 'throws an error when passing one argument passed to grep_curried' );
 
         $obj->_values( [ 2, 4, 22, 99, 101, 6 ] );
 
@@ -574,19 +492,13 @@ sub run_tests {
             'first returns expected value'
         );
 
-        throws_ok { $obj->first }
-        qr/Cannot call first without at least 1 argument/,
-            'throws an error when passing no arguments to first';
+        like( exception { $obj->first }, qr/Cannot call first without at least 1 argument/, 'throws an error when passing no arguments to first' );
 
-        throws_ok {
+        like( exception {
             $obj->first( sub { }, 2 );
-        }
-        qr/Cannot call first with more than 1 argument/,
-            'throws an error when passing two arguments to first';
+        }, qr/Cannot call first with more than 1 argument/, 'throws an error when passing two arguments to first' );
 
-        throws_ok { $obj->first( {} ) }
-        qr/The argument passed to first must be a code reference/,
-            'throws an error when passing a non coderef to first';
+        like( exception { $obj->first( {} ) }, qr/The argument passed to first must be a code reference/, 'throws an error when passing a non coderef to first' );
 
         is(
             $obj->first_curried,
@@ -594,11 +506,9 @@ sub run_tests {
             'first_curried returns expected value'
         );
 
-        throws_ok {
+        like( exception {
             $obj->first_curried( sub { } );
-        }
-        qr/Cannot call first with more than 1 argument/,
-            'throws an error when passing one argument passed to first_curried';
+        }, qr/Cannot call first with more than 1 argument/, 'throws an error when passing one argument passed to first_curried' );
 
         $obj->_values( [ 1 .. 4 ] );
 
@@ -612,17 +522,11 @@ sub run_tests {
             'join returns expected result when joining with empty string'
         );
 
-        throws_ok { $obj->join }
-        qr/Cannot call join without at least 1 argument/,
-            'throws an error when passing no arguments to join';
+        like( exception { $obj->join }, qr/Cannot call join without at least 1 argument/, 'throws an error when passing no arguments to join' );
 
-        throws_ok { $obj->join( '-', 2 ) }
-        qr/Cannot call join with more than 1 argument/,
-            'throws an error when passing two arguments to join';
+        like( exception { $obj->join( '-', 2 ) }, qr/Cannot call join with more than 1 argument/, 'throws an error when passing two arguments to join' );
 
-        throws_ok { $obj->join( {} ) }
-        qr/The argument passed to join must be a string/,
-            'throws an error when passing a non string to join';
+        like( exception { $obj->join( {} ) }, qr/The argument passed to join must be a string/, 'throws an error when passing a non string to join' );
 
         is_deeply(
             [ sort $obj->shuffle ],
@@ -630,9 +534,7 @@ sub run_tests {
             'shuffle returns all values (cannot check for a random order)'
         );
 
-        throws_ok { $obj->shuffle(2) }
-        qr/Cannot call shuffle with any arguments/,
-            'throws an error when passing an argument passed to shuffle';
+        like( exception { $obj->shuffle(2) }, qr/Cannot call shuffle with any arguments/, 'throws an error when passing an argument passed to shuffle' );
 
         $obj->_values( [ 1 .. 4, 2, 5, 3, 7, 3, 3, 1 ] );
 
@@ -642,9 +544,7 @@ sub run_tests {
             'uniq returns expected values (in original order)'
         );
 
-        throws_ok { $obj->uniq(2) }
-        qr/Cannot call uniq with any arguments/,
-            'throws an error when passing an argument passed to uniq';
+        like( exception { $obj->uniq(2) }, qr/Cannot call uniq with any arguments/, 'throws an error when passing an argument passed to uniq' );
 
         $obj->_values( [ 1 .. 5 ] );
 
@@ -654,19 +554,13 @@ sub run_tests {
             'reduce returns expected value'
         );
 
-        throws_ok { $obj->reduce }
-        qr/Cannot call reduce without at least 1 argument/,
-            'throws an error when passing no arguments to reduce';
+        like( exception { $obj->reduce }, qr/Cannot call reduce without at least 1 argument/, 'throws an error when passing no arguments to reduce' );
 
-        throws_ok {
+        like( exception {
             $obj->reduce( sub { }, 2 );
-        }
-        qr/Cannot call reduce with more than 1 argument/,
-            'throws an error when passing two arguments to reduce';
+        }, qr/Cannot call reduce with more than 1 argument/, 'throws an error when passing two arguments to reduce' );
 
-        throws_ok { $obj->reduce( {} ) }
-        qr/The argument passed to reduce must be a code reference/,
-            'throws an error when passing a non coderef to reduce';
+        like( exception { $obj->reduce( {} ) }, qr/The argument passed to reduce must be a code reference/, 'throws an error when passing a non coderef to reduce' );
 
         is(
             $obj->reduce_curried,
@@ -674,11 +568,9 @@ sub run_tests {
             'reduce_curried returns expected value'
         );
 
-        throws_ok {
+        like( exception {
             $obj->reduce_curried( sub { } );
-        }
-        qr/Cannot call reduce with more than 1 argument/,
-            'throws an error when passing one argument passed to reduce_curried';
+        }, qr/Cannot call reduce with more than 1 argument/, 'throws an error when passing one argument passed to reduce_curried' );
 
         $obj->_values( [ 1 .. 6 ] );
 
@@ -703,13 +595,9 @@ sub run_tests {
             'natatime with function returns expected value'
         );
 
-        throws_ok { $obj->natatime( {} ) }
-        qr/The n value passed to natatime must be an integer/,
-            'throws an error when passing a non integer to natatime';
+        like( exception { $obj->natatime( {} ) }, qr/The n value passed to natatime must be an integer/, 'throws an error when passing a non integer to natatime' );
 
-        throws_ok { $obj->natatime( 2, {} ) }
-        qr/The second argument passed to natatime must be a code reference/,
-            'throws an error when passing a non code ref to natatime';
+        like( exception { $obj->natatime( 2, {} ) }, qr/The second argument passed to natatime must be a code reference/, 'throws an error when passing a non code ref to natatime' );
 
         $it = $obj->natatime_curried();
         @nat = ();
@@ -732,9 +620,7 @@ sub run_tests {
             'natatime_curried with function returns expected value'
         );
 
-        throws_ok { $obj->natatime_curried( {} ) }
-        qr/The second argument passed to natatime must be a code reference/,
-            'throws an error when passing a non code ref to natatime_curried';
+        like( exception { $obj->natatime_curried( {} ) }, qr/The second argument passed to natatime must be a code reference/, 'throws an error when passing a non code ref to natatime_curried' );
 
         if ( $class->meta->get_attribute('_values')->is_lazy ) {
             my $obj = $class->new;