From 15df6f9323f018f50f243b9a6faaa797de09e21f Mon Sep 17 00:00:00 2001 From: Zoltan Somogyi Date: Tue, 18 Jun 2019 00:08:10 +0200 Subject: [PATCH] Update the style of some tests. --- tests/general/semi_fail_in_non_ite.m | 57 ++++++++++++++-------------- tests/valid/semi_fail_in_non_ite.m | 55 ++++++++++++++------------- 2 files changed, 57 insertions(+), 55 deletions(-) diff --git a/tests/general/semi_fail_in_non_ite.m b/tests/general/semi_fail_in_non_ite.m index 5094c6214..14030337c 100644 --- a/tests/general/semi_fail_in_non_ite.m +++ b/tests/general/semi_fail_in_non_ite.m @@ -6,6 +6,7 @@ % whose conditions include nondet disjunctions, looking for problems caused % by the disjunction's clobbering some of the same redoip/redofr slots used % for the soft cut in the if-then-else. +% :- module semi_fail_in_non_ite. @@ -13,7 +14,7 @@ :- import_module io. -:- pred main(io__state::di, io__state::uo) is det. +:- pred main(io::di, io::uo) is det. :- implementation. @@ -21,9 +22,9 @@ :- import_module list. :- import_module solutions. -main --> - { solutions(p1, Xs1) }, - print_list(Xs1). +main(!IO) :- + solutions(p1, Xs1), + print_list(Xs1, !IO). :- pred p1(int::out) is nondet. @@ -43,10 +44,13 @@ p3(X) :- :- pred p(int::in, int::out) is nondet. p(A, X) :- - % The first if-then-else can hijack the redoip/redofr slots - % of p's frame. + % The first if-then-else can hijack the redoip/redofr slots of p's frame. ( if - some [B] ( q(A, B) ; r(A, B) ) + some [B] ( + q(A, B) + ; + r(A, B) + ) then C = B * 10 % s(B, C) @@ -55,8 +59,8 @@ p(A, X) :- % s(A, C) ), % The second if-then-else cannot hijack the redoip/redofr slots - % of p's frame, since this may not be (and usually won't be) - % on top when execution gets here. + % of p's frame, since this may not be (and usually won't be) on top + % when execution gets here. ( if some [D] ( q(C, D) @@ -102,31 +106,28 @@ s(F, G) :- G = 10 * F + 1 ). -:- pred print_list(list(int), io__state, io__state). -:- mode print_list(in, di, uo) is det. +:- pred print_list(list(int)::in, io::di, io::uo) is det. -print_list(Xs) --> +print_list(Xs, !IO) :- ( - { Xs = [] } - -> - io__write_string("[]\n") + Xs = [], + io.write_string("[]\n", !IO) ; - io__write_string("["), - print_list_2(Xs), - io__write_string("]\n") + Xs = [_ | _], + io.write_string("[", !IO), + print_list_2(Xs, !IO), + io.write_string("]\n", !IO) ). -:- pred print_list_2(list(int), io__state, io__state). -:- mode print_list_2(in, di, uo) is det. +:- pred print_list_2(list(int)::in, io::di, io::uo) is det. -print_list_2([]) --> []. -print_list_2([X | Xs]) --> - io__write_int(X), +print_list_2([], !IO). +print_list_2([X | Xs], !IO) :- + io.write_int(X, !IO), ( - { Xs = [] } - -> - [] + Xs = [] ; - io__write_string(", "), - print_list_2(Xs) + Xs = [_ | _], + io.write_string(", ", !IO), + print_list_2(Xs, !IO) ). diff --git a/tests/valid/semi_fail_in_non_ite.m b/tests/valid/semi_fail_in_non_ite.m index c58026090..332588245 100644 --- a/tests/valid/semi_fail_in_non_ite.m +++ b/tests/valid/semi_fail_in_non_ite.m @@ -9,6 +9,7 @@ % Unfortunately, we cannot just specify --use-trail for semi_fail_in_non_ite % in tests/general, since that would cause a link error in the usual case % that the runtime being linked with is not in a trailing grade. +% :- module semi_fail_in_non_ite. @@ -24,9 +25,9 @@ :- import_module list. :- import_module solutions. -main --> - { solutions(p1, Xs1) }, - print_list(Xs1). +main(!IO) :- + solutions(p1, Xs1), + print_list(Xs1, !IO). :- pred p1(int::out) is nondet. @@ -46,10 +47,13 @@ p3(X) :- :- pred p(int::in, int::out) is nondet. p(A, X) :- - % The first if-then-else can hijack the redoip/redofr slots - % of p's frame. + % The first if-then-else can hijack the redoip/redofr slots of p's frame. ( if - some [B] ( q(A, B) ; r(A, B) ) + some [B] ( + q(A, B) + ; + r(A, B) + ) then C = B * 10 % s(B, C) @@ -58,8 +62,8 @@ p(A, X) :- % s(A, C) ), % The second if-then-else cannot hijack the redoip/redofr slots - % of p's frame, since this may not be (and usually won't be) - % on top when execution gets here. + % of p's frame, since this may not be (and usually won't be) on top + % when execution gets here. ( if some [D] ( q(C, D) @@ -105,31 +109,28 @@ s(F, G) :- G = 10 * F + 1 ). -:- pred print_list(list(int), io__state, io__state). -:- mode print_list(in, di, uo) is det. +:- pred print_list(list(int)::in, io::di, io::uo) is det. -print_list(Xs) --> +print_list(Xs, !IO) :- ( - { Xs = [] } - -> - io__write_string("[]\n") + Xs = [], + io.write_string("[]\n", !IO) ; - io__write_string("["), - print_list_2(Xs), - io__write_string("]\n") + Xs = [_ | _], + io.write_string("[", !IO), + print_list_2(Xs, !IO), + io.write_string("]\n", !IO) ). -:- pred print_list_2(list(int), io__state, io__state). -:- mode print_list_2(in, di, uo) is det. +:- pred print_list_2(list(int)::in, io::di, io::uo) is det. -print_list_2([]) --> []. -print_list_2([X | Xs]) --> - io__write_int(X), +print_list_2([], !IO). +print_list_2([X | Xs], !IO) :- + io.write_int(X, !IO), ( - { Xs = [] } - -> - [] + Xs = [] ; - io__write_string(", "), - print_list_2(Xs) + Xs = [_ | _], + io.write_string(", ", !IO), + print_list_2(Xs, !IO) ).