Open DavePearce opened 3 weeks ago
In question to the test format, its worth noting there are already a number of simple lisp files in the tests/
directory. They do not have expected evaluation results, however.
For evaluation tests:
BigInt
can be considered a special case.We already have a trace format which looks like this:
{"test": { "A": [0,1,2], "B": [0,-1,-2] }}
Therefore, it would make sense for each module to list the constraints and their evaluation results.
To be honest, accept fail would be good enough as a starting point. Its only when a constraint fails that we have an output which is anything other than 0
!
(module test)
(defcolumns A)
(defpermutation (B) ((+ A)))
;; Enforce that B is always in consecutive order
(defconstraint consecutive ()
(vanishes! (- B 1 (shift B -1))))
A valid input is an array of n
consecutive elements starting from 1
which have been randomly shuffled.
{"test": { "A": [1] } }
{"test": { "A": [1,2] } }
{"test": { "A": [2,1] } }
{"test": { "A": [1,2,3] } }
{"test": { "A": [2,1,3] } }
{"test": { "A": [1,3,2] } }
{"test": { "A": [3,2,1] } }
...
{"test": { "A": [1,2,3,4,5] } }
{"test": { "A": [2] } }
{"test": { "A": [1,3] } }
{"test": { "A": [2,3] } }
{"test": { "A": [3,3] } }
{"test": { "A": [1,2,1] } }
{"test": { "A": [1,2,2] } }
{"test": { "A": [1,2,4] } }
There is currently a small testing framework in the file
src/tests.rs
. However, it only checks that a given set of lisp constraints can be translated into a constraint set. It doesn't actually check what they evaluate to. Some aspects of a good testing framework would be:A key question here is what format the tests should be in. Another question is, of course, what base the outcome data should be in (i.e. naturals or field elements for a given prime, etc).