Not to derail further, but would this be a good use case for the new(ish) isolated transactions? E.g. snapshot/1
:
snapshot/1 allows a thread to examine a frozen state of the dynamic predicates and/or make isolated modifications without affecting other threads and without making permanent changes to the database.
It seems that this is what OP really wants: if they edit the original tests to assert new types of results (say, result2(_)
for simplicity) then they would have to make sure that all the retractions are updated to match, whereas if they do it in a snapshot they can throw away the intermediate state after they’re done without worrying about other ways the database could have been side-effected. Yes?