Re:Stop requiring only one assertion per unit test: Multiple...
by fiddlerwoaroof on Sunday November 06, 2022 @04:40PM
(#33497555)
You can just document a constraint that these function must use the purely functional subset of JavaScript, which is enough for the sorts of assertions I typically write. Alternatively, you could constrain it to the subset that has no unbound variables or side effects.
You can inspect the source, but functions don’t run in isolation so you cannot extract the source and run it somewhere else.
Simple example:
You can’t reliably execute function y with just y’s function body.Maybe if you replace the function with another by injecting code into a copy of the source, but I’m not sure if that’s even possible.