mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 06:47:17 +00:00
Add a couple of new test cases.
tests/general: Add a couple of new test cases. Remove `Entry' and `NP_Entry', since they aren't needed now that I've removed the crud from ../Mmake.
This commit is contained in:
@@ -7,7 +7,10 @@ include ../Mmake
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
PROGS= arithmetic string_test string_test_2 interpreter disj_disj \
|
||||
nondet_disj partition petdr1
|
||||
nondet_disj partition nasty_nondet
|
||||
# We do not yet pass the following tests:
|
||||
# petdr1
|
||||
|
||||
DEPENDS=$(PROGS:%=%.depend)
|
||||
OUTS= $(PROGS:%=%.out)
|
||||
EXPS= $(PROGS:%=%.exp)
|
||||
|
||||
41
tests/general/nasty_nondet.m
Normal file
41
tests/general/nasty_nondet.m
Normal file
@@ -0,0 +1,41 @@
|
||||
:- module nasty_nondet.
|
||||
:- interface.
|
||||
:- import_module io.
|
||||
|
||||
:- pred main(io__state::di, io__state::uo) is det.
|
||||
|
||||
:- implementation.
|
||||
:- import_module list, int, std_util.
|
||||
|
||||
:- pred p(int::in, int::out) is multidet.
|
||||
:- pred q(int::in, int::out) is multidet.
|
||||
|
||||
|
||||
p(Z, Y) :-
|
||||
(if some [X, R] (
|
||||
(X = 1 ; X = 2),
|
||||
q(Z, R),
|
||||
X = R
|
||||
)
|
||||
then
|
||||
Y is X * X + R
|
||||
else
|
||||
Y = 42
|
||||
).
|
||||
|
||||
q(_, 0).
|
||||
q(_, 1).
|
||||
q(_, 2).
|
||||
|
||||
main -->
|
||||
{ solutions(p(100), List) },
|
||||
write_int_list(List).
|
||||
|
||||
:- pred write_int_list(list(int)::in, io__state::di, io__state::uo) is det.
|
||||
|
||||
write_int_list([]) --> [].
|
||||
write_int_list([X|Xs]) -->
|
||||
io__write_int(X),
|
||||
io__write_string("\n"),
|
||||
write_int_list(Xs).
|
||||
|
||||
45
tests/general/nondet_ite.m
Normal file
45
tests/general/nondet_ite.m
Normal file
@@ -0,0 +1,45 @@
|
||||
% nondet_ite.m: test nondet if-then-else with nondet condition.
|
||||
|
||||
:- module nondet_ite.
|
||||
:- interface.
|
||||
:- import_module io.
|
||||
|
||||
:- pred main(io__state::di, io__state::uo) is det.
|
||||
|
||||
:- implementation.
|
||||
:- import_module list, int, std_util.
|
||||
|
||||
:- pred q(int::out, int::out) is nondet.
|
||||
|
||||
q(X, Y) :-
|
||||
p(X),
|
||||
(if some [Y1] p(Y1) then
|
||||
Y = Y1
|
||||
else
|
||||
Y = 42
|
||||
).
|
||||
|
||||
:- pred p(int::out) is nondet.
|
||||
|
||||
p(0).
|
||||
p(1).
|
||||
p(2).
|
||||
|
||||
:- pred r(int::out) is nondet.
|
||||
|
||||
r(Z) :-
|
||||
q(X, Y),
|
||||
Z is X * 100 + Y.
|
||||
|
||||
main -->
|
||||
{ solutions(r, List) },
|
||||
write_int_list(List).
|
||||
|
||||
:- pred write_int_list(list(int)::in, io__state::di, io__state::uo) is det.
|
||||
|
||||
write_int_list([]) --> [].
|
||||
write_int_list([X|Xs]) -->
|
||||
io__write_int(X),
|
||||
io__write_string("\n"),
|
||||
write_int_list(Xs).
|
||||
|
||||
Reference in New Issue
Block a user