Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert return value #101

Open
OoDeLally opened this issue Nov 24, 2017 · 2 comments
Open

assert return value #101

OoDeLally opened this issue Nov 24, 2017 · 2 comments
Labels

Comments

@OoDeLally
Copy link

Would it be possible to powerAssert the return value?
something like

const functionWhichShouldReturnNumber = (x) => {
  assertReturn(Number.isNumber)
  ...
  return 'bad return type'
}
@azu azu added the question label Nov 24, 2017
@twada
Copy link
Member

twada commented Nov 25, 2017

@OoDeLally Thank you for your question!

Short answer: not possible now.

Ensuring postconditions in terms of assertion programming is nice and what I'm interested in.

However, it's not a target of power-assert project. It causes scope creep.

When an idea has come I'll create another tool to enforce postconditions then use it in combination with power-assert. I'm very very interested in creating it.

Thanks and please feel free to ask any questions!

@OoDeLally
Copy link
Author

It seems sensible to me to add it to powerassert, as it will share most of its code with powerassert.
Since powerassert is already transpiled, how hard would it be to add an assertion check before every return within covered functions?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants