Files
mercury/tests/hard_coded/exceptions/test_exceptions_func.m
Peter Ross f1784ab668 Adapt the tests in the hard_coded directory so that the version of the
Estimated hours taken: 8

Adapt the tests in the hard_coded directory so that the version of the
Mercury compiler built with MSVC passes them in the hlc.gc grade.

tests/hard_coded/deep_copy.exp2:
tests/hard_coded/expand.exp2:
tests/hard_coded/float_reg.exp2:
tests/hard_coded/string_loop.exp2:
tests/hard_coded/write.exp2:
tests/hard_coded/write_reg1.exp2:
    The MSVC runtime prints out floating points using three digits for
    the exponent instead of two for most other runtimes.

tests/hard_coded/remove_file.m:
    s/io__tmp_name/io__make_tmp/ as tmp_name is obsolete.

tests/hard_coded/Mmakefile:
    Remove test_bitset and add bitset.

tests/hard_coded/bitset.exp:
tests/hard_coded/bitset.m:
tests/hard_coded/bitset_tester.m:
tests/hard_coded/test_bitset.exp:
tests/hard_coded/test_bitset.m:
    Move this test into one test case because mmake falls over with
    unable to make `std_util.m^M', plus there is no reason to have this
    case spread over two files.

tests/hard_coded/exceptions/test_exceptions_func.m:
    Remove the uneeded import of std_util, this avoids the
    `std_util.m^M' problem mentioned in the previous test case.
2001-02-13 15:57:27 +00:00

57 lines
1.7 KiB
Mathematica

%---------------------------------------------------------------------------%
% Copyright (C) 1997-1998 The University of Melbourne.
% This file may only be copied under the terms of the GNU Library General
% Public License - see the file COPYING.LIB in the Mercury distribution.
%---------------------------------------------------------------------------%
% File: test_exceptions_func.m.
% Main author: fjh.
% Test cases for exception handling functions.
% XXX we should test nested exception handlers.
%-----------------------------------------------------------------------------%
:- module test_exceptions_func.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is cc_multi.
:- implementation.
:- import_module exception.
main -->
{ try(det_throw, R1) },
print("det_throw: "), print_r(R1), nl,
{ try(det_succeed, R2) },
print("det_succeed: "), print_r(R2), nl,
{ try(semidet_throw, SemidetThrowResult) },
print("semidet_throw: "), print_r(SemidetThrowResult), nl,
{ try(semidet_succeed, SemidetSucceedResult) },
print("semidet_succeed: "), print_r(SemidetSucceedResult), nl,
{ try(semidet_fail, SemidetFailResult) },
print("semidet_fail: "), print_r(SemidetFailResult), nl.
:- pred print_r(exception_result(T)::in, io__state::di, io__state::uo) is det.
print_r(E) --> print(E).
:- pred det_throw(string::out) is det.
det_throw(throw("det_throw")).
:- pred semidet_throw(string::out) is semidet.
semidet_throw(throw("semidet_throw")).
:- pred det_succeed(string::out) is det.
det_succeed("det_succeed").
:- pred semidet_succeed(string::out) is semidet.
semidet_succeed("semidet_succeed").
:- pred semidet_fail(string::out) is semidet.
semidet_fail("semidet_fail") :- fail.