• R/O
  • HTTP
  • SSH
  • HTTPS

transunit: Commit

Transunit repository


Commit MetaInfo

Revision8740fd37ee9873188bc0701e3cc6722a4fcae41f (tree)
Zeit2019-05-12 11:15:27
AutorAlaskanEmily <yoloshart@gmai...>
CommiterAlaskanEmily

Log Message

Use correct typeclass in compare_tests

Ändern Zusammenfassung

Diff

--- a/transunit.compare.m
+++ b/transunit.compare.m
@@ -59,6 +59,10 @@
5959
6060 %------------------------------------------------------------------------------%
6161
62+:- func simple_compare(T, T) = maybe.maybe_error.
63+
64+%------------------------------------------------------------------------------%
65+
6266 :- func negate(float) = float.
6367
6468 %------------------------------------------------------------------------------%
@@ -150,6 +154,11 @@ generic_compare(A, B) = Result :-
150154
151155 %------------------------------------------------------------------------------%
152156
157+simple_compare(A, B) = Result :-
158+ ( A = B -> Result = maybe.ok ; Result = maybe.error("Not equal") ).
159+
160+%------------------------------------------------------------------------------%
161+
153162 :- pred accumulate_mismatch(T, T, list(string), list(string), int, int)
154163 <= compare(T).
155164 :- mode accumulate_mismatch(in, in, in, out, in, out) is det.
--- a/transunit.compare_test.m
+++ b/transunit.compare_test.m
@@ -31,7 +31,8 @@
3131
3232 %-----------------------------------------------------------------------------%
3333 % NOTE: this runner does NOT catch exceptions!
34-:- pred run_test(pred(A, B), A, B, maybe.maybe_error).
34+:- pred run_test(pred(A, B), A, B, maybe.maybe_error)
35+ <= compare(B).
3536 :- mode run_test(pred(in, out) is det, in, in, out) is det.
3637 :- mode run_test(pred(di, out) is det, di, in, out) is det.
3738 :- mode run_test(pred(in, out) is cc_multi, in, in, out) is det.
@@ -43,7 +44,8 @@
4344
4445 %-----------------------------------------------------------------------------%
4546
46-:- pred run_test(pred(A, B, State, State), A, B, maybe.maybe_error, State, State).
47+:- pred run_test(pred(A, B, State, State), A, B, maybe.maybe_error, State, State)
48+ <= compare(B).
4749 :- mode run_test(pred(in, out, di, uo) is det, in, in, out, di, uo) is det.
4850 :- mode run_test(pred(in, out, in, out) is det, in, in, out, in, out) is det.
4951 :- mode run_test(pred(di, out, di, uo) is det, di, in, out, di, uo) is det.
@@ -55,7 +57,8 @@
5557
5658 %-----------------------------------------------------------------------------%
5759
58-:- pred run_test(pred(T, State, State), T, maybe.maybe_error, State, State).
60+:- pred run_test(pred(T, State, State), T, maybe.maybe_error, State, State)
61+ <= compare(T).
5962 :- mode run_test(pred(out, di, uo) is det, in, out, di, uo) is det.
6063 :- mode run_test(pred(out, in, out) is det, in, out, in, out) is det.
6164 :- mode run_test(pred(out, di, uo) is cc_multi, in, out, di, uo) is det.
@@ -66,13 +69,15 @@
6669 % error is transformed into the maybe_error result using io.error_message.
6770 % If the result is io.ok, the value is tested against the expected result as
6871 % usual.
69-:- pred run_io_test(pred(A, io.res(B), State, State), A, B, maybe.maybe_error, State, State).
72+:- pred run_io_test(pred(A, io.res(B), State, State), A, B, maybe.maybe_error, State, State)
73+ <= compare(B).
7074 :- mode run_io_test(pred(in, out, di, uo) is det, in, in, out, di, uo) is det.
7175 :- mode run_io_test(pred(di, out, di, uo) is det, di, in, out, di, uo) is det.
7276
7377 %-----------------------------------------------------------------------------%
7478 % Similar to run_test/6, but supports semidet inputs.
75-:- pred run_backtrack_test(pred(A, B, State, State), A, B, maybe.maybe_error, State, State).
79+:- pred run_backtrack_test(pred(A, B, State, State), A, B, maybe.maybe_error, State, State)
80+ <= compare(B).
7681 :- mode run_backtrack_test(pred(in, out, in, out) is semidet, in, in, out, in, out) is det.
7782 :- mode run_backtrack_test(pred(in, out, mdi, muo) is semidet, in, in, out, mdi, muo) is det.
7883 :- mode run_backtrack_test(pred(mdi, out, in, out) is semidet, mdi, in, out, in, out) is det.
@@ -82,7 +87,8 @@
8287 :- mode run_backtrack_test(pred(mdi, out, in, out) is cc_nondet, mdi, in, out, in, out) is det.
8388 :- mode run_backtrack_test(pred(mdi, out, mdi, muo) is cc_nondet, mdi, in, out, mdi, muo) is det.
8489
85-:- pred run_backtrack_test(pred(T, State, State), T, maybe.maybe_error, State, State).
90+:- pred run_backtrack_test(pred(T, State, State), T, maybe.maybe_error, State, State)
91+ <= compare(T).
8692 :- mode run_backtrack_test(pred(out, in, out) is semidet, in, out, in, out) is det.
8793 :- mode run_backtrack_test(pred(out, mdi, muo) is semidet, in, out, mdi, muo) is det.
8894 :- mode run_backtrack_test(pred(out, in, out) is cc_nondet, in, out, in, out) is det.
@@ -92,12 +98,6 @@
9298 :- implementation.
9399 %=============================================================================%
94100
95-% DUMMY
96-:- func compare(T, T) = maybe.maybe_error.
97-
98-compare(A, B) = Result :-
99- ( A = B -> Result = maybe.ok ; Result = maybe.error("!=") ).
100-
101101 %-----------------------------------------------------------------------------%
102102
103103 run_test(Pred, In, Out, Result) :-
Show on old repository browser