-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtesting.pl
42 lines (40 loc) · 1.87 KB
/
testing.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
% Debugging
:-op(920, fy, ?).
:-op(920, fy, ??).
??(Goal):-
setup_call_catcher_cleanup(format(user_error, 'CALL ~q~n', [Goal]),
Goal,
Catcher,
( Catcher == fail ->
format(user_error, 'FAIL ~q~n', [Goal])
; Catcher == exit ->
format(user_error, 'EXIT ~q~n', [Goal])
; Catcher == ! ->
format(user_error, 'CUT ~q~n', [Goal])
; Catcher = error(Error)->
format(user_error, 'ERROR ~q ~p~n', [Goal, Error])
)),
( var(Catcher)->
format(user_error, 'PEND ~q~n', [Goal])
; otherwise->
true
).
?(Goal):-
functor(Goal, Functor, Arity),
setup_call_catcher_cleanup(format(user_error, 'CALL ~q~n', [Functor/Arity]),
Goal,
Catcher,
( Catcher == fail ->
format(user_error, 'FAIL ~q~n', [Goal])
; Catcher == exit ->
format(user_error, 'EXIT ~q~n', [Functor/Arity])
; Catcher == ! ->
format(user_error, 'CUT ~q~n', [Functor/Arity])
; Catcher = error(Error)->
format(user_error, 'ERROR ~q ~p~n', [Functor/Arity, Error])
)),
( var(Catcher)->
format(user_error, 'PEND ~q~n', [Functor/Arity])
; otherwise->
true
).