-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_tools.pl
More file actions
26 lines (22 loc) · 1.02 KB
/
Copy pathdebug_tools.pl
File metadata and controls
26 lines (22 loc) · 1.02 KB
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
% debug_tools.pl
:-include('pretty_print_table.pl').
:-include('sub_term_with_address.pl').
test_p(A) :- (catch(call_with_time_limit(10,A),_,(writeln(["Predicate timed out:",A]),abort))->true;(writeln(["Predicate failed:",A]),fail%abort
)),!.
test_p_woto(A) :- (catch(A,_,fail)->true;(writeln(["Predicate failed:",A]),%fail,
abort
)),!.
test_r(A,B) :-
sub_term_types_wa([string,number,atom,[]],A,Instances1),
sub_term_types_wa([string,number,atom,[]],B,Instances2),
(Instances1=Instances2->true;
(subtract(Instances1,Instances2,Instances1a),
subtract(Instances2,Instances1,Instances2a),
(pretty_print_table([A],A1)->true;pretty_print_table([[A]],A1)),
(pretty_print_table([B],B1)->true;pretty_print_table([[B]],B1)),
pretty_print_table([Instances1a],Instances1a1),
pretty_print_table([Instances2a],Instances2a1),
writeln(["**********","\n","Error in result:",A1,"\n**********","\n","given correct result:",B1,"\n**********","\n","Missing terminals:",Instances1a1,
"\n**********","\n","Incorrect terminals:",Instances2a1]),
true%abort
)),!.