mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-05-01 17:24:34 +00:00
Estimated hours taken: 4 Various fixes to the test cases so that they work with `__' as a module qualifier. tests/general/commit_bug.m: tests/general/mode_info_bug.m: tests/general/partition.m: tests/hard_coded/string_alignment.m: Delete `nl' predicate (and replace calls with calls to `io__nl') to avoid ambiguities with `io__nl'. tests/general/partition.m: Rename `write' as `write_s' to avoid ambiguities with `io__write'. tests/warnings/singleton_test.m: tests/warnings/singleton_test.exp: tests/warnings/pragma_source_code.m: tests/warnings/pragma_source_code.exp: s/append/my_append/g to avoid ambiguities with `list__append'. tests/general/parse_list.m: tests/general/semidet_map.m: s/meta__/meta_/g to avoid errors about defining `meta__blah' in a module other than `meta'. tests/hard_coded/qual_strang.m: tests/hard_coded/qual_strung.m: s/string__//g to avoid errors about defining `string__blah' in a module other than `string'. tests/valid/middle_rec_bug.m: s/garbage_out__/garbage_out_/g to avoid errors about defining `garbage_out__blah' in a module other than `garbage_out'. tests/hard_coded/qual_basic_test.m: tests/hard_coded/qual_adv_test.m: Eliminate double quantifiers, e.g. delete the `io__' in `io:io__write_string'. Also test calling `write_string' without `io:' or `io__'.
61 lines
1.4 KiB
Mathematica
61 lines
1.4 KiB
Mathematica
% This is a regression test - a previous version of the compiler
|
|
% got an internal compiler error when compiling this file.
|
|
% (Thanks to Bart Demoen for this test.)
|
|
|
|
/* Running this program yields
|
|
213
|
|
4
|
|
|
|
|
|
*** Mercury runtime: caught segmentation violation ***
|
|
cause: address not mapped to object
|
|
PC at signal: 120476 (1d69c)
|
|
address involved: 8
|
|
exiting from signal handler
|
|
*/
|
|
|
|
:- module partition.
|
|
:- interface.
|
|
:- import_module io, int, list, std_util.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is multidet.
|
|
|
|
:- implementation.
|
|
|
|
main -->
|
|
{ solutions(bug, List) },
|
|
( { List = [] } ->
|
|
io__write_string("No solution\n")
|
|
;
|
|
print_solnlist(List)
|
|
).
|
|
|
|
:- pred print_solnlist(list(pair(list(int)))::in, io__state::di, io__state::uo)
|
|
is det.
|
|
|
|
print_solnlist([]) --> [].
|
|
print_solnlist([Le - Gr | Rest]) -->
|
|
print_intlist(Le),
|
|
print_intlist(Gr),
|
|
io__nl,
|
|
print_solnlist(Rest).
|
|
|
|
:- pred bug(pair(list(int))::out) is nondet.
|
|
|
|
bug(Le - Gr) :-
|
|
part(3,[4,2,1,3], Le, Gr).
|
|
|
|
:- pred part(int,list(int),list(int),list(int)).
|
|
:- mode part(in,in,out,out) is nondet.
|
|
part(_X, [], [], []).
|
|
part(X, [Y|L], [Y|Le], Gr):-
|
|
Y =< X, part(X, L, Le, Gr).
|
|
part(X, [Y|L], Le, [Y|Gr]):-
|
|
Y > X, part(X, L, Le, Gr).
|
|
|
|
:- pred print_intlist(list(int)::in,io__state::di, io__state::uo) is det.
|
|
print_intlist([])--> io__nl.
|
|
print_intlist([X|L])--> io__write_int(X), print_intlist(L).
|
|
|
|
:- end_module partition.
|