Skip to content

Commit a8ca88f

Browse files
committed
Start to add ground truth "sanity checks"
1 parent 3212faa commit a8ca88f

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

share/prolog/oorules/insanity.pl

+28
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33
% Sanity checking rules
44
% ============================================================================================
55

6+
:- table haveGround/0 as opaque.
7+
haveGround :- groundTruth(_, _, _, _, _, _, _, _, _), !.
8+
9+
% If we have ground truth, did we merge two different classes together?
10+
:- table insanityGroundBadMerge/1 as incremental.
11+
insanityGroundBadMerge(Out) :-
12+
13+
find(M1, C),
14+
groundTruth(M1, C1, Mname1, _, _, _, _, _, _),
15+
find(M2, C),
16+
iso_dif(M1, M2),
17+
groundTruth(M2, C2, Mname2, _, _, _, _, _, _),
18+
iso_dif(C1, C2),
19+
20+
% Make sure that this method is not on multiple classes
21+
not(groundTruth(M2, C1, _, _, _, _, _, _, _)),
22+
23+
Out = (
24+
logwarnln('Consistency checks failed.~n~Q (~Q::~Q) and ~Q (~Q::~Q) are on the same class, but ground truth says they are on ~Q and ~Q.', [M1, C1, Mname1, M2, C2, Mname2, C1, C2])
25+
).
26+
27+
628
% If we say we have no base classes, we have no base classes :-)
729
:- table insanityNoBaseConsistency/1 as incremental.
830
insanityNoBaseConsistency(Out) :-
@@ -330,6 +352,7 @@
330352

331353
:- table sanityChecks/1 as incremental.
332354
sanityChecks(Out) :-
355+
groundSanityChecks(Out);
333356
insanityNoBaseConsistency(Out);
334357
insanityEmbeddedAndNot(Out);
335358
insanityConstructorAndNotConstructor(Out);
@@ -348,6 +371,11 @@
348371
insanityContradictoryNOTConstructor(Out);
349372
insanityTwoRealDestructorsOnClass(Out).
350373

374+
groundSanityChecks(Out) :-
375+
haveGround,
376+
377+
insanityGroundBadMerge(Out).
378+
351379
sanityChecks :-
352380
sanityChecks(Out)
353381
->

share/prolog/oorules/ooprolog.pl

+11-4
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@
240240
generate_results(Opts) :-
241241
check_option(facts(Facts), Opts),
242242
option(results(Results), Opts), !,
243+
load_ground(Opts),
243244
( current_prolog_flag(break_level, _) % interactive session
244245
-> psolve_no_halt(Facts)
245246
; setup_call_cleanup(
@@ -269,17 +270,23 @@
269270
run_with_backtrace(exportJSONTo(JsonFile))
270271
; true.
271272

272-
%% If there is a ground option, validate results
273-
validate_results(Opts) :-
273+
load_ground(Opts) :-
274274
check_option(ground(Ground), Opts) ->
275275
setup_call_cleanup(
276276
open(Ground, read, Stream),
277277
run_with_backtrace(
278-
(loadPredicates(stream(Stream)),
279-
validateResults)),
278+
loadPredicates(stream(Stream))
279+
),
280280
close(Stream))
281281
; true.
282282

283+
%% If there is a ground option, validate results
284+
validate_results(Opts) :-
285+
check_option(ground(_Ground), Opts) ->
286+
(load_ground(Opts),
287+
validateResults)
288+
; true.
289+
283290
/* Local Variables: */
284291
/* mode: prolog */
285292
/* fill-column: 95 */

0 commit comments

Comments
 (0)