More tests should be written as quads
Please see how expected and unexpected answers can now be directly embedded in programs, using quads, i.e., queries using answer descriptions:
https://github.com/mthom/scryer-prolog/blob/87f5295bd01e59c0387083b2de2b38e48ad1e310/src/lib/numerics/special_functions.pl#L46
https://github.com/mthom/scryer-prolog/blob/87f5295bd01e59c0387083b2de2b38e48ad1e310/src/lib/numerics/quadtests.pl#L104
@dcnorris has generously contributed initial support for using quads as tests: quadtests.pl
All current and future tests residing in tests-pl are candidates for using this approach: Let's embed toplevel interactions in these files to denote the expected answers. This would allow us to simplify the tests, and ideally also make the same mechanism available to applications.
Is anyone interested in helping with this? I would greatly appreciate your support, thank you a lot!
One way to 'normalize' quads might be to rework the basic libraries to use them in documentation. This would also present a good opportunity to exhibit MGQ's wherever possible.
Currently, e.g., lists:nth1/3 is documented like this:
%% nth1(?N, ?Ls, ?E).
%
% Succeeds if in the N position of the list Ls, we found the element E. The elements start counting from one.
%
% ```
% ?- nth1(2, [1,2,3,4], 2).
% true.
% ```
nth1(N, Es0, E) :-
N \== 0,
nth0(N, [_|Es0], E),
N \== 0.
Me, every time I look at our libraries:
I think quad tests page must be fixed to: https://www.scryer.pl/numerics/quadtests.html