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.
runtime/mercury_float.c:
Fix a bug in MR_sprintf_float where it would convert 1.8e-10
into "1.80000000000000e-1" instead of "1.8e-10".
The problem was that it was stripping the zeros off the end of the string
produced by sprintf without considering the case where the output
was in scientific notation.
The fix is to remove the `#' from the sprintf format string and then to
append ".0" to the string if there is no "." or "e".
tests/general/float_roundtrip.m:
tests/general/float_roundtrip.exp:
Add regression test.
tests/hard_coded/deep_copy.exp:
tests/hard_coded/expand.exp:
tests/hard_coded/float_reg.exp:
tests/hard_coded/write.exp:
tests/hard_coded/write_binary.exp:
tests/hard_coded/write_reg1.exp:
tests/hard_coded/write_xml.exp:
Update the expected output of these tests as trailing zeros are now
also removed from the base part of scientific notation float strings.
Estimated hours taken: 8
Branches: main
Fix the I/O routines for floats so that can roundtrip.
library/string.m:
Ensure that string__float_to_string returns a float that is
round-trippable. On the C backend we do that by starting at the min
precision required and increasing it until the float roundtrips.
This functionality is provided by ML_sprintf_float, so that it can
be reused in io.m. On the IL backend the R flag guarantees that a
double will be round-trippable, so we just use that.
Change string__to_float so that it uses the format string for the
precision float that we are using, and export this predicate for use
by the trace system.
Delete the unused string__float_to_f_string.
library/io.m:
Print round-tripable floats in io__write_float.
For the C backend use ML_sprintf_float to avoid unnecessary string
allocation. For other backends use string__float_to_string to
generate a valid float.
trace/mercury_trace_util.c:
Rather than duplicating the code from the library, call the code in
the library.
tests/general/Mmakefile:
tests/general/float_roundtrip.exp:
tests/general/float_roundtrip.m:
Test that floats roundtrip for different required miniumum
precisions.