Robert-van-Engelen / tinylisp

Lisp in 99 lines of C and how to write one yourself. Includes 20 Lisp primitives, garbage collection and REPL. Includes tail-call optimized versions for speed and reduced memory use.
BSD 3-Clause "New" or "Revised" License
851 stars 37 forks source link

Add tests #7

Closed Luv2C0d3 closed 1 year ago

Luv2C0d3 commented 1 year ago

PLEASE DO NOT MERGE THIS!!!

Hello, prof Van Engelen. Thanks for setting up this project. I was playing a bit with it trying to add tests and I needed to re-factor a things in order to be able to use Unity which is a test framework extremely lightweight, for embedded projects. I copied tinylisp-commented.c and created a variant called tinylisp-tested.c, where I abstracted the initialization to tinylisp_init() and moved some things to tinylisp.h, such that I could re-initialize the system / re-use things from the test cases in file test-tl-test.c.

Note: If this were to be merged I would delete the tinylisp-tested and just modify tinylisp-commented to make it testable, and I would remove / squash commits and vscode files. I would leave the makefile(s) and Unity bits.

My question is whether you think this would add value? Based on that I will keep playing and possibly after having good tests for the main mechanisms, thus scan, read, parse, list, I would proceed with LISP based tests as it seems more fun and self-hosted.

Robert-van-Engelen commented 1 year ago

Thanks for contributing. I think that adding tests is a good idea. Keeping things small and simple is the goal. So as long as the project has no dependencies on other projects and the project structure is clear (to beginners) then I'm OK with adding test. Adding tests as a separate directory to build and run is my preference. So it won't "clutter" the root directory.