Files
mercury/tests/valid/state_var_mode_bug2.m
Zoltan Somogyi fdd141bf77 Clean up the tests in the other test directories.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
    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 tests
    that check compiler error messages, expect the new line numbers.

browser/cterm.m:
browser/tree234_cc.m:
    Import only one module per line.

tests/hard_coded/boyer.m:
    Fix something I missed.
2015-02-16 12:32:18 +11:00

98 lines
2.1 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et
%---------------------------------------------------------------------------%
%
% Author: Ralph Becket <rafe@cs.mu.oz.au>
%
% This is a regression test for a bug involving the interaction of the mode
% system and quantification, triggered by the state variable transformation.
%
% This version expands out the state variable transformation.
%
%---------------------------------------------------------------------------%
:- module state_var_mode_bug2.
:- interface.
:- import_module bool.
:- import_module int.
:- pred p(bool::in, bool::in, int::in, int::out) is semidet.
:- implementation.
p(A, B, !Y) :-
some [X0, _X] (
p0(X0),
p2(X0, X1),
p2(X1, X2),
(
A = yes
->
(
B = yes,
p1(X2),
p2(X2, X3),
p1(X3),
X4 = X3
;
B = no,
(
p1(X2),
p2(X2, X3)
->
p1(X3),
X4 = X3
;
X4 = X2
)
),
X5 = X4
;
(
p1(X2),
p2(X2, X3)
->
(
A = yes,
p1(X3),
p2(X3, X4),
(
B = yes,
p2(X4, X5)
;
B = no,
X5 = X4
)
;
A = no,
X5 = X3
)
;
p1(X2)
->
p1(X2),
p2(X2, X3),
p1(X3),
X5 = X3
;
X5 = X2
)
),
_X = X5
).
:- pred p0(int::out) is det.
p0(0).
:- pred p1(int::in) is semidet.
p1(1).
:- pred p2(int::in, int::out) is semidet.
p2(X0, X0) :-
p1(X0).