power-assert
power-assert copied to clipboard
assert return value
Would it be possible to powerAssert the return value? something like
const functionWhichShouldReturnNumber = (x) => {
assertReturn(Number.isNumber)
...
return 'bad return type'
}
@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!
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!