mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 11:23:46 +00:00
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the debugger tests,
specify the new line numbers in .inp files and expect them in .exp files.
49 lines
1.3 KiB
Mathematica
49 lines
1.3 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% This module, originally written by Philip Dart,
|
|
% uncovered a (second) bug in the implementation of semidet predicates
|
|
% in Mercury version 0.4.
|
|
%
|
|
|
|
:- module parse_list.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
:- import_module list.
|
|
:- import_module std_util.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
|
|
:- pred meta_parse_list(pred(Y, Y, X), list(X), Y, Y).
|
|
:- mode meta_parse_list(pred(in, out, out) is semidet, out, in, out) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module builtin.
|
|
:- import_module int.
|
|
:- import_module string.
|
|
|
|
main -->
|
|
{P = (pred(I::in, O::out, N::out) is semidet :- one_or_two(N, I, O))},
|
|
( {meta_parse_list(P, [X, Y], [2, 1, 3], _)} ->
|
|
{string__int_to_string(X, SX)},
|
|
{string__int_to_string(Y, SY)},
|
|
io__write_strings(["Success: X = ", SX, "; Y = ", SY, ".\n"])
|
|
;
|
|
io__write_string("Failure.\n")
|
|
).
|
|
|
|
meta_parse_list(P, L, In, Out) :-
|
|
( call(P, In, Out0, E) ->
|
|
L = [E | L1], meta_parse_list(P, L1, Out0, Out)
|
|
;
|
|
L = [], Out = In
|
|
).
|
|
|
|
:- pred one_or_two(int::out, list(int)::in, list(int)::out) is semidet.
|
|
|
|
one_or_two(1) --> [1].
|
|
one_or_two(2) --> [2].
|