Developer Scratch Pad
Lisp challenge 8 — string evaluation debugging

So I spent some time trying to figure out what the problem was with my command-line version of my testing framework. The problem was that I gave it as an input the following forms in a file,

(qtest “first test” (ok true))
(qtest “second test” (ok false))
(qtest “third test” (ok false))

and I got back as the output,

1 tests. 0 passed. 1 failed.
‘first test’ failed. Expected true. Actual: false.

Which is obviously wrong. I had already ran into a similar bug, so I knew that it had to do with something connected with the sequence. After a few troubleshooting, I figured that only the result of the last test was being processed. Much later I confirmed this behavior via the clojure documentation

load et al return the value produced by the last expression.

So I had to figure out a way to return a single form. Easy, now my input file read like this:

[(qtest “first test” (ok true))
(qtest “second test” (ok false))
(qtest “third test” (ok false))]

Later on I may add a function that will add the vector brackets. For right now it is a minor issue. So now load-string was behaving correctly. However, my function run-specky() doesn’t take a vector as an argument. It takes many individual tests. So I needed a way to unwrap the collection.

And apply() came to the rescue. As the stack overflow article says, apply will unwrap the sequence and feed the sequence as arguments to the function.
so from this

(run-specky [result1 result2 result3 ])

using apply we get

(run-specy result1 result3 result3)

Which is what I want. Now the function looks like this:

(apply run-specky
 (load-string
  (slurp (first *command-line-args*))))

——
About  the project


And with that I finished my first version of the testing library. I want to try the music library in clojure, which will introduce me to using non-core libraries. At some point I will just dive into learning how to write macros. I want to hold back on learning macros until I absolutely need them. Unfortunately it seems that I can get most of my needs done without using them. I will not feel that I know lisp until I can write macros.

Before diving into more clojure, I am going to take some time to look at another lisp, racket.