mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +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.
55 lines
1.3 KiB
Mathematica
55 lines
1.3 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
:- module unicode_test.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module char.
|
|
:- import_module list.
|
|
:- import_module string.
|
|
|
|
main(!IO) :-
|
|
list.foldl(write_string_as_binary, utf8_strings, !IO),
|
|
io.nl(!IO),
|
|
Str = string.join_list("(☿)\n", utf8_strings),
|
|
io.write_string(Str, !IO),
|
|
io.nl(!IO).
|
|
|
|
:- func utf8_strings = list(string).
|
|
|
|
utf8_strings = [
|
|
"\u0003",
|
|
"\U00000003",
|
|
"\u0394", % delta
|
|
"\u03A0", % pi
|
|
"\uFFFD",
|
|
"\U0010fffd",
|
|
"\U000ABCde",
|
|
"r\u00E9sum\u00E9", % "resume" with accents
|
|
"abc123",
|
|
"\u005cu0041",
|
|
"\x5c\u0041",
|
|
"\x5c\\u0041",
|
|
"\\u0041",
|
|
"u0041"
|
|
].
|
|
|
|
:- pred write_string_as_binary(string::in, io::di, io::uo) is det.
|
|
|
|
write_string_as_binary(Str, !IO) :-
|
|
Chars = string.to_char_list(Str),
|
|
Ints = list.map(to_int, Chars),
|
|
Bins = list.map(( func(X) = int_to_base_string(X, 2) ), Ints),
|
|
PaddedBins = list.map(( func(S) = pad_left(S, '0', 8) ), Bins),
|
|
Bin = string.join_list(" ", PaddedBins),
|
|
io.write_string(Bin, !IO),
|
|
io.nl(!IO).
|