Files
mercury/tests/hard_coded/remove_file.m
Julien Fischer 5cbbc2fd34 Fix the failure of hard_coded/remove_file in the Java grade.
tests/hard_coded/remove_file.exp3:
    Add an alternative expected output for this one.  This current
    output is the best we can do while we still support Java 1.5
    and 1.6.

tests/hard_coded/remove_file.m:
    Update syntax.
2016-02-23 14:45:38 +11:00

60 lines
2.0 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% If this test fails when run natively under Win32 (no cygwin) then make
% sure that either the TMPDIR environment variable points somewhere
% sensible or that a directory <drive letter>:\tmp exists.
:- module remove_file.
:- interface.
:- use_module io.
:- pred main(io.state::di, io.state::uo) is det.
:- implementation.
main(!IO) :-
io.make_temp(Name, !IO),
%%%%%%% io.print("Temp file name = ", !IO), io.print_line(Name, !IO),
io.tell(Name, TellResult, !IO),
(
TellResult = io.ok,
io.print_line("Just testing", !IO),
io.told(!IO),
io.remove_file(Name, RemoveResult, !IO),
(
RemoveResult = io.ok,
io.see(Name, SeeResult, !IO),
( if SeeResult = io.ok then
io.print("Remove didn't remove file\n", !IO),
io.set_exit_status(1, !IO)
else
io.print("Test passed\n", !IO)
)
;
RemoveResult = io.error(RemoveError),
io.print("Remove failed: ", !IO),
io.error_message(RemoveError, RemoveErrorMsg),
io.print_line(RemoveErrorMsg, !IO),
io.set_exit_status(1, !IO)
),
io.remove_file(Name, RemoveAgainResult, !IO),
(
RemoveAgainResult = io.ok,
io.print("Second remove didn't report failure\n", !IO),
io.set_exit_status(1, !IO)
;
RemoveAgainResult = io.error(RemoveAgainError),
io.print("Second remove failed, as expected: ", !IO),
io.error_message(RemoveAgainError, RemoveAgainErrorMsg),
io.print_line(RemoveAgainErrorMsg, !IO)
)
;
TellResult = io.error(TellError),
io.print("Tell failed: ", !IO),
io.error_message(TellError, TellErrorMsg),
io.print_line(TellErrorMsg, !IO),
io.set_exit_status(1, !IO)
).