💾 Archived View for idiomdrottning.org › make-tests captured on 2022-04-29 at 12:26:59. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
➡️ Next capture (2022-06-11)
-=-=-=-=-=-=-
If you like hacking Scheme on Emacs and evaling expressions from buffers (just checking in the REPL to see if things look right), this little app is great for turning that into (kinda shabby) unit tests in a tests/run.scm file.
So if you have made a procedure called + that adds numbers, and you check it in the REPL by evaling
(+ 10 2 300)
and you think it looks right, this app’ll turn that into a test that looks like this:
(unless (equal? 312 (+ 10 2 300)) (error "(+ 10 2 300)"))
Any pre-existing forms in a pre-existing tests/run.scm are kept, and duplicates across the two files are removed, but comments and such are lost, so be careful.
Either have a separate file in your source directory (this file does not need to be checked into VCS) or move things into such a file from whereever you have them, and then
make-tests /my/sloppy/old/repl-testing-file.scm
Also put any imports and defines that are needed to run the tests.
This will create
/my/sloppy/old/tests/run.scm
Look through it, edit it until you’re happy etc. Again, re-running make-tests will clobber any formatting, commenting etc that you do in there, so be careful.
For source code,
git clone https://idiomdrottning.org/make-tests