So… I'm pretty sure there's a double evaluation bug in the testing library. It looks like the test suite is working around this bug because each call to xtmtest looks like:
(xtmtest '(setup-a-fixture-usually-by-binding-a-func)
form-that-evaluates-to-a-number-or-other-self-eval-value #98
Quoting the setup protects from the double eval, and the call part always evaluating to a simple constant protects that too. The test macros are also unhygenic and the test suite is written with that assumption. There's lots of code like:
(xtmtest `(bind-func test_something (lambda (x) ...))
(test_something 1) #t)
(xtmtest-result (test_something 2) #372
This means we have to be very careful about naming test functions and the like or test suites could interfere with each other. So, I propose the following (and there will be pull requests incoming)
- Writing a new
xtmtest-with-fixture macro that would work something like:
(xtmtest-with-fixture
(bind-func test_list_membership
(lambda (x)
(let ((lst (list 1 2 3))
(result (member x lst)))
(if (not (null? result))
(println "list contains" x)
(println "list does not contain" x))
(not (null? result)))))
(test_list_membership 2) 1)
(test_list_membership 4) 0))
- Test this new macro
- Rewrite the test suite to use this new macro
- Eliminate
xtmtest (and potentially rename xtmtest-with-fixture back to xtmtest
- Fix double evaluation in
xtmtest-compile
So… I'm pretty sure there's a double evaluation bug in the testing library. It looks like the test suite is working around this bug because each call to
xtmtestlooks like:(xtmtest '(setup-a-fixture-usually-by-binding-a-func) form-that-evaluates-to-a-number-or-other-self-eval-value #98Quoting the setup protects from the double eval, and the
callpart always evaluating to a simple constant protects that too. The test macros are also unhygenic and the test suite is written with that assumption. There's lots of code like:This means we have to be very careful about naming test functions and the like or test suites could interfere with each other. So, I propose the following (and there will be pull requests incoming)
xtmtest-with-fixturemacro that would work something like:(xtmtest-with-fixture (bind-func test_list_membership (lambda (x) (let ((lst (list 1 2 3)) (result (member x lst))) (if (not (null? result)) (println "list contains" x) (println "list does not contain" x)) (not (null? result))))) (test_list_membership 2) 1) (test_list_membership 4) 0))xtmtest(and potentially renamextmtest-with-fixtureback toxtmtestxtmtest-compile