<div dir="ltr">Gambit community,<div><br></div><div>I was thinking about automated testing in general, and I thought to myself, "why aren't automated tests collocated with the respective procedures under test?"  So, using what I've learned from various emails from Marc over the years [1] [2], I made a test framework [3] which collocates tests with their definitions, executes the tests at compile-time only (well, Marc calls it expansion-time); and should those tests fail, no executable nor shared library is produced.  If they pass, the tests are not included in the resulting executable.  I'm not aware of any other test framework in existence which does this, but I think that the collocation is incredibly helpful, and it helps to make programs in a "literate programming" style [4].  It helps to answer questions like "What was the author intending when he/she wrote this?" "How is this procedure intended to be used?", with no need to jump around between files.</div><div><br></div><div>Attached is an implementation of this test framework in standard Gambit syntax, or you could look at <a href="https://github.com/billsix/bug/blob/master/src/main.bug.scm">https://github.com/billsix/bug/blob/master/src/main.bug.scm</a>, which is written in BUG scheme syntax (it's basically a pre-processed Gambit with support for lambda literals: very informally ['foo] turns into (lambda () 'foo), and [|x y z| (a x y z)] turns into (lambda (x y z) (a x y z)))</div><div><br></div><div>In creating this project, I also came to the realization that compilers can also be interpreters capable of any computation, including I/O.  In my mind this opens up a lot of possibilities beyond syntactic abstraction via macros.  Besides the unit test suite, BUG automatically exports both namespace declarations and macros definitions to files at compile time, for use by projects which link to libbug.</div><div><br></div><div>Thanks for Gambit.</div><div><br></div><div>Bill</div><div><br></div><div>[1] <a href="https://mercure.iro.umontreal.ca/pipermail/gambit-list/2006-May/000690.html">https://mercure.iro.umontreal.ca/pipermail/gambit-list/2006-May/000690.html</a> (by evaluating all procedures and macros at expansion time as part of the test, it also solves the problem listed in referenced email)</div><div>[2] <a href="https://mercure.iro.umontreal.ca/pipermail/gambit-list/2005-June/000305.html">https://mercure.iro.umontreal.ca/pipermail/gambit-list/2005-June/000305.html</a></div><div>[3] <a href="https://github.com/billsix/bug">https://github.com/billsix/bug</a>  It's not just a test framework, it's Bill's Utilities for Gambit (BUG).  (currently only builds on Linux, because I haven't ported the build process yet)</div><div>[4] <a href="https://en.wikipedia.org/wiki/Literate_programming">https://en.wikipedia.org/wiki/Literate_programming</a></div><div><br></div></div>