-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.pl
49 lines (39 loc) · 1.18 KB
/
test.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% TESTS - FRAMEWORK FOR SELF-TEST AND REGRESSION TESTS
:- module(test, [regression_test/0, self_test/0, module_test/2]).
regression_test :- % external functionality tests
param:regression_test_modules(R),
forall(member(M,R), module_test(M,regression_test)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
self_test :- % internal self-tests
% report_test(<module>:self_test),
param:self_test_modules(S),
( S \== []
-> writeln('Self Tests:')
; true
),
forall(member(M,S), module_test(M,self_test)),
true.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
module_test(Module,TestCategory) :-
call(Module:TestCategory),
true.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
report_test(G) :- % argument is a test goal
write(G), write(' ... '),
( call(G)
-> writeln('ok')
; writeln('failed')
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
regression_test(M) :-
param:test_directory_name(D),
atom_concat([M,'.pl'], '.', Mfilename),
atomic_list_concat([D, '/', M, '_test.pl'], Tfilename),
exists_file(Mfilename), exists_file(Tfilename),
atomic_list_concat([M,':',M,'_regression_tests'],Rfunct),
Q =.. [Rfunct,Rlist],
call(Q),
forall(member(R,Rlist), report_test(M:R)),
true.
test_case_passed(M,T) :-
format('~a:~a Passed~n',[M,T]).