Here’s the translation of the Go testing and benchmarking example to Lisp (Common Lisp), formatted for Hugo:
This Lisp code demonstrates testing and benchmarking concepts similar to the original Go example. Here’s a brief explanation of the changes:
We use the FiveAM testing framework, which is a popular choice for Common Lisp.
Tests are defined using the test macro instead of functions starting with “Test”.
The is macro is used for assertions, similar to t.Error in Go.
Table-driven tests are implemented using a list of lists and a loop.
Benchmarking is implemented manually using get-internal-real-time to measure execution time.
The run-tests-and-benchmark function combines running tests and the benchmark.
To run the tests and benchmark, you would typically load this file into your Lisp environment and call (run-tests-and-benchmark). The output would show the test results and the benchmark timing.
Note that Common Lisp doesn’t have a built-in testing or benchmarking tool like Go’s go test command. Instead, we use external libraries like FiveAM for testing, and implement benchmarking manually or use other profiling tools available in the Lisp environment.