Skip to content

Instantly share code, notes, and snippets.

@rsrchboy

rsrchboy/More.pm Secret

Created July 30, 2015 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsrchboy/08c107475f3c37842747 to your computer and use it in GitHub Desktop.
Save rsrchboy/08c107475f3c37842747 to your computer and use it in GitHub Desktop.
sub validate_thing { _validate_subtest_wrapper(\&_validate_thing_guts, @_) }
sub validate_class { _validate_subtest_wrapper(\&_validate_class_guts, @_) }
sub validate_role { _validate_subtest_wrapper(\&_validate_role_guts, @_) }
sub _validate_subtest_wrapper {
my ($func, $thing, %args) = @_;
# note incrementing by 2 because of our upper curried function
local $Test::Builder::Level = $Test::Builder::Level + 2;
# run tests w/o a subtest wrapper...
return $func->($thing => %args)
unless $args{-subtest};
# ...or with one.
return $tb->subtest(delete $args{-subtest} => sub { $func->($thing => %args) });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment