Files
mercury/tests/hard_coded/deep_copy_bug.m
Julien Fischer 1f6d83692a Update programming style in tests/hard_coded.
tests/hard_coded/*.m:
    Update programming style, unless doing so would change
    the meaning of the test, in particular:

    - use '.' as a module qualifier in place of '__'
    - use {write,print}_line where appropriate
    - use if-then-else in place of C -> T ; E
    - use state variables in place of DCGs

tests/hard_coded/dir_test.m:
    Document what the expected outputs correspond to.

    Use a uniform module qualifier in the output.

tests/hard_coded/dir_test.exp*:
    Conform to the above change.
2021-01-07 13:58:12 +11:00

65 lines
1.4 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% This is a regression test.
% The Mercury compiler of Apr 11 1997 failed for this in non-gc grades,
% because of a bug in deep_copy() of equivalence types.
:- module deep_copy_bug.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module int.
:- import_module list.
:- import_module solutions.
:- import_module term.
:- import_module varset.
main(!IO) :-
test1(!IO),
test2(!IO),
test3(!IO).
:- pred test1(io::di, io::uo) is det.
test1(!IO) :-
Lambda = (pred(X::out) is nondet :-
varset.init(Varset0),
varset.new_vars(10, Vars, Varset0, _),
list.member(X, Vars)
),
solutions(Lambda, List),
io.write_line(List, !IO).
:- pred test2(io::di, io::uo) is det.
test2 -->
test2b("blahblah").
:- pred test2b(T::in, io::di, io::uo) is det.
test2b(S, !IO) :-
F = foo(S),
solutions(F, List),
io.write_line(List, !IO).
:- pred foo(T, var).
:- mode foo(in, out) is nondet.
foo(Blah, X) :-
varset.init(Varset0),
varset.new_vars(10, Vars, Varset0, _),
list.member(X, Vars).
:- pred test3(io::di, io::uo) is det.
test3(!IO) :-
solutions((pred(X::out) is nondet :- bar(X)), List),
io.write_line(List, !IO).
:- pred bar(int).
:- mode bar(out) is det.
bar(42).