Skip to content

Commit a1a04da

Browse files
committed
Fix UT
1 parent 6376456 commit a1a04da

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

tests/scryer/cli/issues/incorrect_arithmetics.in/incorrect_arithmetics.pl

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,45 @@
55
:- use_module(library(format)).
66
:- use_module(library(debug)).
77
:- use_module(library(time)).
8-
9-
:- dynamic(rznvivy/0).
8+
:- use_module(library(gensym)).
109

1110
% Asserting and consulting of erroneous arithmetic relation shall succeed,
1211
% but then it must fail at runtime.
1312
main :-
14-
template_relation("ttftf", R),
15-
ignore_exception(test(R, consult)),
16-
%ignore_exception(test(R, assert)),
17-
true.
13+
template_relation("tttft", R),
14+
load_test(assertz, R),
15+
load_test(reconsult, R).
1816

19-
test(Relation, TestVariant) :-
20-
load_and_call(TestVariant, rznvivy/0, (rznvivy :- false, Relation), \+rznvivy).
17+
load_test(Setup, Body) :-
18+
portray_clause(start:Setup),
19+
gensym(test, Test),
20+
setup_call_cleanup(
21+
ignore_exception(call(Setup, (Test :- false, Body))),
22+
(
23+
(ignore_exception(listing(Test/0)),!;true),
24+
\+ignore_exception(Test) -> Result = pass; Result = fail
25+
),
26+
ignore_exception(retractall(Test))
27+
),
28+
portray_clause(Result:Setup).
2129

22-
load_and_call(assert, PI, Clause, Query) :-
30+
reconsult(Clause) :-
31+
Clause = (Head :- Body),
32+
File = 'chnytjl.pl',
33+
portray_consult(File, (canary :- Body)),
2334
setup_call_cleanup(
24-
ignore_exception(assertz(Clause)),
25-
callf(PI, Query),
26-
$retract(Clause)
35+
assertz(Head),
36+
portray_consult(File, Clause),
37+
retract(Head)
2738
).
28-
load_and_call(consult, PI, Clause, Query) :-
29-
T = 'chnytjl.pl',
39+
40+
portray_consult(File, Clause) :-
3041
setup_call_cleanup(
31-
open(T, write, S),
42+
open(File, write, S),
3243
portray_clause(S, Clause),
3344
close(S)
3445
),
35-
setup_call_cleanup(
36-
ignore_exception(consult(T)),
37-
callf(PI, Query),
38-
$retract(Clause)
39-
).
40-
41-
callf(PI, G_0) :-
42-
clause(rznvivy, I),
43-
I \= true,
44-
always(ignore_exception(listing(PI))),
45-
$G_0.
46-
47-
always(G_0) :- call(G_0).
48-
always(_).
46+
consult(File).
4947

5048
template_relation(Template, R) :-
5149
time(setof(E, phrase(arith_relation(E), Template), Es)),

0 commit comments

Comments
 (0)