use Test::With; sub foo : WithTests( 2 ) { my ($x, $y) = @_; return $x + y; } with_test { cmp_ok( foo( 4, 3 ), '==', 7 ); cmp_ok( foo( -6, 2 ), '==', -4 ); };