I want to use plunit as implemented in SWI Prolog to run a few unit tests in classy style!
So I want to enter them directly on the terminal:
[user].
and then copy paste:
:- begin_tests(exercise).
test(foo) :- bar.
:- end_tests(exercise).
This works perfectly.
... but if I load the test via [user]. again -- there is a Westworld-like experience:
?- [user].
|: :- begin_tests(exercise).
ERROR: user://2:17:
ERROR: module/2: No permission to redefine module `plunit_exercise' (Already loaded from user://1)
Warning: user://2:17:
Warning: Goal (directive) failed: user:begin_tests(exercise)
It seems that the implementation creates a Module plunit_X for test X. That makes sense.
But is there a way to unload the test module exercise?
There must be...
Note that you can unload a file with unload_file/1 but not a Module?
Update:
Instead of entering the code using [user]. and using a [file] makes it work. Hmm.