mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-20 11:54:02 +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.
90 lines
2.1 KiB
Mathematica
90 lines
2.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Test reading terms with min_int arguments.
|
|
|
|
:- module read_min_int.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
:- import_module list.
|
|
:- import_module string.
|
|
|
|
:- type foo
|
|
---> foo(int).
|
|
|
|
main(!IO) :-
|
|
% Test io.read.
|
|
test_stdin(!IO),
|
|
io.nl(!IO),
|
|
|
|
% Test io.read_from_string.
|
|
io.open_input("read_min_int.inp", OpenRes, !IO),
|
|
(
|
|
OpenRes = ok(Stream),
|
|
test_read_from_string(Stream, !IO),
|
|
io.close_input(Stream, !IO)
|
|
;
|
|
OpenRes = error(Error),
|
|
io.write(Error, !IO),
|
|
io.nl(!IO)
|
|
).
|
|
|
|
:- pred test_stdin(io::di, io::uo) is det.
|
|
|
|
test_stdin(!IO) :-
|
|
io.read(Res, !IO),
|
|
(
|
|
Res = ok(X : foo),
|
|
io.write(X, !IO),
|
|
io.nl(!IO),
|
|
test_stdin(!IO)
|
|
;
|
|
Res = error(Error, _),
|
|
io.write_string(Error, !IO),
|
|
io.nl(!IO),
|
|
test_stdin(!IO)
|
|
;
|
|
Res = eof
|
|
).
|
|
|
|
:- pred test_read_from_string(io.input_stream::in, io::di, io::uo) is det.
|
|
|
|
test_read_from_string(Stream, !IO) :-
|
|
io.read_line_as_string(Stream, IORes, !IO),
|
|
(
|
|
IORes = ok(String),
|
|
FileName = "",
|
|
Posn0 = posn(1, 0, 0),
|
|
io.read_from_string(FileName, String, length(String), Res,
|
|
Posn0, _Posn),
|
|
(
|
|
Res = ok(X : foo),
|
|
io.write(X, !IO),
|
|
io.nl(!IO)
|
|
;
|
|
Res = eof
|
|
;
|
|
Res = error(Error, _),
|
|
io.write_string(Error, !IO),
|
|
io.nl(!IO)
|
|
),
|
|
test_read_from_string(Stream, !IO)
|
|
;
|
|
IORes = eof
|
|
;
|
|
IORes = error(IOError),
|
|
io.write_string(io.error_message(IOError), !IO),
|
|
io.nl(!IO)
|
|
).
|