diff: array_test.m
Andrew Bromage
bromage at cs.mu.oz.au
Tue Jul 29 14:19:26 AEST 1997
G'day.
Fergus, could you review this one please?
Cheers,
Andrew Bromage
Estimated hours taken: 0.5
Changes to make array_test.m run under NU-Prolog.
tests/general/array_test.m:
Remove one function call (use the predicate version) and
replace calls to io__write with their typed versions.
Index: array_test.m
===================================================================
RCS file: /home/staff/zs/imp/tests/general/array_test.m,v
retrieving revision 1.1
diff -u -r1.1 array_test.m
--- 1.1 1997/07/25 05:16:13
+++ array_test.m 1997/07/29 04:10:26
@@ -20,7 +20,7 @@
{
Cmp = lambda([X :: in, Y :: in, Res :: out] is det,
compare(Res, X, Y)),
- A0 = array(Xs),
+ array__from_list(Xs, A0),
array__to_list(A0, As0),
array__max(A0, AMax0),
array__min(A0, AMin0),
@@ -34,16 +34,16 @@
array__shrink(A2, 10, A3),
array__to_list(A3, As3)
},
- write_message("A0: ", As0),
- write_message("AMax0: ", AMax0),
- write_message("AMin0: ", AMin0),
- write_message("ASize: ", ASize),
- write_message("AMin1: ", AMin1),
- write_message("AMax1: ", AMax1),
- write_message("ABsearch: ", ABsearch),
- write_message("A1: ", As1),
- write_message("A2: ", As2),
- write_message("A3: ", As3),
+ write_message_int_list("A0: ", As0),
+ write_message_int("AMax0: ", AMax0),
+ write_message_int("AMin0: ", AMin0),
+ write_message_int("ASize: ", ASize),
+ write_message_int("AMin1: ", AMin1),
+ write_message_int("AMax1: ", AMax1),
+ write_message_maybe_int("ABsearch: ", ABsearch),
+ write_message_int_list("A1: ", As1),
+ write_message_int_list("A2: ", As2),
+ write_message_int_list("A3: ", As3),
{
bt_array__from_list(0, Xs, B0),
bt_array__to_list(B0, Bs0),
@@ -63,16 +63,16 @@
bt_array__shrink(B2, 0, 9, B3),
bt_array__to_list(B3, Bs3)
},
- write_message("B0: ", Bs0),
- write_message("BMax0: ", BMax0),
- write_message("BMin0: ", BMin0),
- write_message("BSize: ", BSize),
- write_message("BMin1: ", BMin1),
- write_message("BMax1: ", BMax1),
- write_message("BBsearch: ", BBsearch),
- write_message("B1: ", Bs1),
- write_message("B2: ", Bs2),
- write_message("B3: ", Bs3),
+ write_message_int_list("B0: ", Bs0),
+ write_message_int("BMax0: ", BMax0),
+ write_message_int("BMin0: ", BMin0),
+ write_message_int("BSize: ", BSize),
+ write_message_int("BMin1: ", BMin1),
+ write_message_int("BMax1: ", BMax1),
+ write_message_maybe_int("BBsearch: ", BBsearch),
+ write_message_int_list("B1: ", Bs1),
+ write_message_int_list("B2: ", Bs2),
+ write_message_int_list("B3: ", Bs3),
% Finally, just in case, compare the two implementations.
(
@@ -100,12 +100,48 @@
io__write_string("Results don't match\n")
).
-:- pred write_message(string, T, io__state, io__state).
-:- mode write_message(in, array_ui, di, uo) is det.
-:- mode write_message(in, in, di, uo) is det.
+:- pred write_message_int(string, int, io__state, io__state).
+:- mode write_message_int(in, in, di, uo) is det.
-write_message(Msg, O) -->
+write_message_int(Msg, O) -->
io__write_string(Msg),
- io__write(O),
+ io__write_int(O),
io__nl.
+
+:- pred write_message_maybe_int(string, maybe(int), io__state, io__state).
+:- mode write_message_maybe_int(in, in, di, uo) is det.
+
+write_message_maybe_int(Msg, no) -->
+ io__write_string(Msg),
+ io__write_string("no"),
+ io__nl.
+write_message_maybe_int(Msg, yes(I)) -->
+ io__write_string(Msg),
+ io__write_string("yes("),
+ io__write_int(I),
+ io__write_string(")"),
+ io__nl.
+
+:- pred write_message_int_list(string, list(int), io__state, io__state).
+:- mode write_message_int_list(in, in, di, uo) is det.
+
+write_message_int_list(Msg, List) -->
+ io__write_string(Msg),
+ ( { List = [] },
+ io__write_string("[]")
+ ; { List = [I | Is] },
+ io__write_char('['),
+ io__write_int(I),
+ write_int_list_rest(Is)
+ ),
+ io__nl.
+
+:- pred write_int_list_rest(list(int), io__state, io__state).
+:- mode write_int_list_rest(in, di, uo) is det.
+write_int_list_rest([]) -->
+ io__write_char(']').
+write_int_list_rest([I | Is]) -->
+ io__write_string(", "),
+ io__write_int(I),
+ write_int_list_rest(Is).
More information about the developers
mailing list