mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
Extend the operations that perform formatted conversion, such as string.format/2, to be able to handle values of type uint directly. We have always supported formatting values of type int as unsigned values, but currently the only way to format uint values is by explicitly casting them to an int. This addresses Mantis issue #502. library/string.m: Add a new alternative to the poly_type/0 type that wraps uint values. Update the documentation for string.format. uint values may now be formatted using the u, x, X, o or p conversion specifiers. library/string.format.m: Add the necessary machinery for handling formatting of uint values. library/string.parse_runtime.m: library/string.parse_util.m: Handle uint poly_types. library/io.m:a Handle uint values in the write_many predicates. library/pprint.m: Handle uint values in the poly/1 function. compiler/format_call.m: compiler/parse_string_format.m: Conform to the above changes. compiler/options.m: Add a way to detect if a compiler supports this change. NEWS: Announce the above changes. tests/hard_coded/stream_format.{m,exp}: Extend this test to cover uints. tests/invalid/string_format_bad.m: tests/invalid/string_format_unknown.m: Conform to the above changes. tests/string_format/Mmakefile: tests/string_format/string_format_uint_o.{m,exp,exp2}: tests/string_format/string_format_uint_u.{m,exp,exp2}: tests/string_format/string_format_uint_x.{m,exp,exp2}: Add tests of string.format with uints.
35 lines
968 B
Mathematica
35 lines
968 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Test the u specifier of string.format with uint values.
|
|
%
|
|
% The .exp file is for when uint is 32-bit.
|
|
% The .exp2 file is for when uint is 64-bit.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module string_format_uint_u.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int.
|
|
:- import_module list.
|
|
:- import_module string.
|
|
:- import_module string_format_lib.
|
|
:- import_module uint.
|
|
|
|
main(!IO) :-
|
|
UInts = [u(0u), u(1u), u(10u), u(100u), u(max_uint)],
|
|
list.foldl(output_list(UInts), format_strings("u"), !IO).
|
|
|
|
%---------------------------------------------------------------------------%
|