So I'm looking for tools / processes, or reasons to not have functions and tests in the same source file. "If literate programming didn't yet catch on, that shows the idea is wrong" someone said. But Jupyter Notebooks work quite well. So maybe it's the tooling, not the idea, that needs to be improved.
I don't want to ship the test code into production builds (I think?) and that all code gets the same linting and basic static code sanity checks.
This seems to imply:
- Tests should rather not be written as comments (doctest style)
- Some preprocessing needed (babel-plugin or Sweet.js macro)
- Some tweaking needed for highlighting and build pipelines, unless I compromise and just go the doctest route.
- Books about testing JS, Contracts and Aspect Oriented Programming if that can be used for my goals, Ullman's Compilers... book, Assman's Software Composition on a hunch.
- (Asking in the wrong place, hopefully it's OK to ask here.)
Looking at existing tools:
- doctest looks quite good.
- power-doctest is an impressive in-editor Proof of concept and looks like an extension of 1. though I didn't manage to translate from japanese to get to the details.
- doctest-js might be the best option if you want python doctest (but maybe I don't?
- This Sweet.js-based experiment with a macro to implement racket-style code tests.
But the tools found mostly work like python's doctest. What am I missing? Is this approach even valid / popular anywhere?