r/ProgrammingLanguages • u/HaskellLisp_green • Jun 24 '26
Help Documentation and testing
Hello, I finished my bachelor thesis that is development of Lisp interpreter. It is implemented in C(GNU99).
I need some tips on how to organize documentation(formal specification) of my custom Lisp dialect and the way to test interpreter.
Currently my documentation is couple of org files. Index is the root file with links to particular notes: data types, special forms, primitive functions.
File "data-types.org" provide enumeration of existing types and their properties.
File "special-forms.org" and "primitive-functions.org" provide similar enumerations. For each special form or primitive function I define arguments number, arguments type and description.
(Beside these documentation entries there are notes on architecture, building, interning, e.t.c)
So I consider documentation as the source of truth. If actual behavior doesn't match documentation, it's a bug. For example, car expects exactly 1 argument of list type. So it should fail and raise error message if type is different.
My question is how to define full test suite that covers whole interpreter? I have several ideas. I have already implemented python script that requires particular build and tests. Each test is made of script and associated expected output. I think for each component there should be positive and negative tests. But how can I say that given set of test cases for given primitive function, special form, e.t.c. is enough?
Also what are good practices of writing programming language documentation?
View all comments
Show parent comment
5
u/Big-Rub9545 Jun 24 '26
Splitting to keep each comment shorter.
As for testing:
The main goal should be to test every thing that you promise to the user. For example, if your language spec or documentation specifies that primitive function “func” accepts argument types X and Y but not Z, then you should test its output for each of these three.
This should be the primary objective when writing tests. However, it doesn’t guarantee that everything will be perfect. This is just an aspect of software (and even moreso PL) design that you just have to live with. Even extremely reliable language implementations like gcc or clang have subtle bugs that users report. This is why it’s also important to open ways for users to give feedback or report issues in the behavior of your language.
It may be somewhat objectionable to some, but AI can also work well here to write a lot of these tests for you. You should verify its output, of course (particularly since your language is new and it has no data to generate correct code or tests from), but it does a good job in speeding up the process as well as testing some important edge cases (especially for features that many other languages have).