Skip to content

Oddness in the test suite #385

@pdcawley

Description

@pdcawley

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)

  1. 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))
  1. Test this new macro
  2. Rewrite the test suite to use this new macro
  3. Eliminate xtmtest (and potentially rename xtmtest-with-fixture back to xtmtest
  4. Fix double evaluation in xtmtest-compile

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions