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:

  1. Tests should rather not be written as comments (doctest style)
  2. Some preprocessing needed (babel-plugin or Sweet.js macro)
  3. Some tweaking needed for highlighting and build pipelines, unless I compromise and just go the doctest route.

I tried:

  • 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:

    1. doctest looks quite good.
    2. 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.
    3. doctest-js might be the best option if you want python doctest (but maybe I don't?
    4. 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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.