mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 09:53:36 +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.
78 lines
2.7 KiB
Mathematica
78 lines
2.7 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%---------------------------------------------------------------------------%
|
|
% Test the constant function float.infinity/0.
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module test_infinity.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module bool.
|
|
:- import_module float.
|
|
:- import_module list.
|
|
:- import_module math.
|
|
:- import_module string.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
main(!IO) :-
|
|
% Test io.write_float with infinity.
|
|
%
|
|
io.write_string("write_float(infinity) = ", !IO),
|
|
io.write_float(infinity, !IO),
|
|
io.nl(!IO),
|
|
io.write_string("write_float(-infinity) = ", !IO),
|
|
io.write_float(-infinity, !IO),
|
|
io.nl(!IO),
|
|
|
|
% Test format with infinity.
|
|
%
|
|
io.format("to %f and beyond!\n", [f(infinity)], !IO),
|
|
io.format("format(-infinity) = %f\n", [f(-infinity)], !IO),
|
|
|
|
% Test float classification predicates with infinity.
|
|
%
|
|
io.format("is_infinite(infinity) = %s\n",
|
|
[s(string(pred_to_bool(is_infinite(infinity))))], !IO),
|
|
io.format("is_infinite(-infinity) = %s\n",
|
|
[s(string(pred_to_bool(is_infinite(-infinity))))], !IO),
|
|
|
|
io.format("is_finite(infinity) = %s\n",
|
|
[s(string(pred_to_bool(is_finite(infinity))))], !IO),
|
|
io.format("is_finite(-infinity) = %s\n",
|
|
[s(string(pred_to_bool(is_finite(-infinity))))], !IO),
|
|
|
|
io.format("is_nan(infinity) = %s\n",
|
|
[s(string(pred_to_bool(is_nan(infinity))))], !IO),
|
|
io.format("is_nan(-infinity) = %s\n",
|
|
[s(string(pred_to_bool(is_nan(-infinity))))], !IO),
|
|
|
|
io.format("is_zero(infinity) = %s\n",
|
|
[s(string(pred_to_bool(is_nan(infinity))))], !IO),
|
|
io.format("is_zero(-infinity) = %s\n",
|
|
[s(string(pred_to_bool(is_zero(-infinity))))], !IO),
|
|
|
|
% Test abs with infinities.
|
|
%
|
|
io.format("abs(infinity) = %f\n", [f(abs(infinity))], !IO),
|
|
io.format("abs(-infinity) = %f\n", [f(abs(-infinity))], !IO),
|
|
|
|
% Test for pow.
|
|
% XXX most other uses of infinity with pow currently cause a domain error
|
|
% -- this is at variance with what IEEE 754-2008 says should happen in many
|
|
% cases.
|
|
io.format("pow(infinity, 0) = %f\n", [f(pow(infinity, 0))], !IO).
|
|
|
|
%---------------------------------------------------------------------------%
|
|
:- end_module test_infinity.
|
|
%---------------------------------------------------------------------------%
|