mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-30 00:34:40 +00:00
tests/hard_coded/*.m:
Rename modules as mentioned above.
In a few cases, where the main module's name itself had a suffix,
such as "_mod_a" or "_main", remove that suffix. This entails
renaming the .exp file as well. (In some cases, this meant that
the name of a helper module was "taken over" by the main module
of the test case.)
Update all references to the moved modules.
General updates to programming style, such as
- replacing DCG notation with state var notation
- replacing (C->T;E) with (if C then T else E)
- moving pred/func declarations to just before their code
- replacing io.write/io.nl sequences with io.write_line
- replacing io.print/io.nl sequences with io.print_line
- fixing too-long lines
- fixing grammar errors in comments
tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
Update all references to the moved modules.
Enable the constant_prop_int test case. The fact that it wasn't enabled
before is probably an accident. (When constant_prop_int.m was created,
the test case was added to a list in the Mmakefile, but that list
was later removed due to never being referenced.)
tests/hard_coded/constant_prop_int.{m,exp}:
Delete the calls to shift operations with negative shift amounts,
since we have added a compile-time error for these since the test
was originally created.
83 lines
2.0 KiB
Mathematica
83 lines
2.0 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module factt_non.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
:- pred main(io::di, io::uo) is cc_multi.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module bool.
|
|
:- import_module float.
|
|
:- import_module int.
|
|
:- import_module list.
|
|
:- import_module maybe.
|
|
:- import_module pair.
|
|
:- import_module solutions.
|
|
:- import_module string.
|
|
|
|
:- pred example(int, float, string).
|
|
:- mode example(in, in, in) is semidet.
|
|
:- mode example(in, in, out) is nondet.
|
|
:- mode example(in, out, out) is nondet.
|
|
:- mode example(out, out, out) is multi.
|
|
|
|
:- pragma fact_table(example/3, "factt_non_examples").
|
|
|
|
main(!IO) :-
|
|
test_in_in_in(Result1),
|
|
test_in_in_out(Result2),
|
|
test_in_out_out(Result3),
|
|
test_out_out_out(Result4),
|
|
io.print_line(Result1, !IO),
|
|
io.print_line(Result2, !IO),
|
|
io.print_line(Result3, !IO),
|
|
io.print_line(Result4, !IO).
|
|
|
|
:- pred test_in_in_in(pair(bool)::out) is det.
|
|
|
|
test_in_in_in(Res1 - Res2) :-
|
|
Res1 = ( if example(2, 2.0, "2.0") then yes else no ),
|
|
Res2 = ( if example(42, 2.0, "foobar") then yes else no ).
|
|
|
|
:- pred test_in_in_out(pair(maybe(string))::out) is cc_multi.
|
|
|
|
test_in_in_out(Res1 - Res2) :-
|
|
Res1 = ( if example(42, 3.0, S1) then yes(S1) else no ),
|
|
Res2 = ( if example(42, 2.0, S2) then yes(S2) else no ).
|
|
|
|
:- pred test_in_out_out(pair(maybe(string))::out) is cc_multi.
|
|
|
|
test_in_out_out(Res1 - Res2) :-
|
|
( if
|
|
example(42, F1, S1),
|
|
F1 > 10.0
|
|
then
|
|
Res1 = yes(S1)
|
|
else
|
|
Res1 = no
|
|
),
|
|
( if
|
|
example(2, F2, S2),
|
|
F2 > 10.0
|
|
then
|
|
Res2 = yes(S2)
|
|
else
|
|
Res2 = no
|
|
).
|
|
|
|
:- pred test_out_out_out(list(string)::out) is det.
|
|
|
|
test_out_out_out(Res) :-
|
|
Pred =
|
|
( pred(S::out) is nondet :-
|
|
example(N, F, S),
|
|
( N > 10
|
|
; F < 1.5
|
|
)
|
|
),
|
|
solutions(Pred, Res).
|