mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-28 07:44:43 +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.
68 lines
1.7 KiB
Mathematica
68 lines
1.7 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Test the declarative debugger's handling of I/O streams.
|
|
|
|
:- module io_stream_test.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io__state, io__state).
|
|
:- mode main(di, uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module char.
|
|
:- import_module int.
|
|
:- import_module list.
|
|
|
|
main -->
|
|
io__open_input("tabled_read_decl.data", Res),
|
|
( { Res = ok(Stream) } ->
|
|
io_stream_test__part_1(Stream),
|
|
io_stream_test__part_2(Stream)
|
|
;
|
|
io__write_string("could not open tabled_read.data\n")
|
|
).
|
|
|
|
:- pred io_stream_test__part_1(io__input_stream::in,
|
|
io__state::di, io__state::uo) is det.
|
|
|
|
io_stream_test__part_1(Stream) -->
|
|
io_stream_test__test(Stream, A),
|
|
io__write_int(A),
|
|
io__nl.
|
|
|
|
:- pred io_stream_test__part_2(io__input_stream::in,
|
|
io__state::di, io__state::uo) is det.
|
|
|
|
io_stream_test__part_2(Stream) -->
|
|
io_stream_test__test(Stream, A),
|
|
io__write_int(A),
|
|
io__nl.
|
|
|
|
:- pred io_stream_test__test(io__input_stream::in, int::out,
|
|
io__state::di, io__state::uo) is det.
|
|
|
|
io_stream_test__test(Stream, N) -->
|
|
% BUG: the 1 should be 0
|
|
io_stream_test__test_2(Stream, 1, N).
|
|
|
|
:- pred io_stream_test__test_2(io__input_stream::in, int::in, int::out,
|
|
io__state::di, io__state::uo) is det.
|
|
|
|
io_stream_test__test_2(Stream, SoFar, N) -->
|
|
io__read_char(Stream, Res),
|
|
(
|
|
{ Res = ok(Char) },
|
|
{ char__is_digit(Char) },
|
|
{ char__digit_to_int(Char, CharInt) }
|
|
->
|
|
io_stream_test__test_2(Stream, SoFar * 10 + CharInt, N)
|
|
;
|
|
{ N = SoFar }
|
|
).
|