mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 18:03:36 +00:00
47 lines
1.1 KiB
Mathematica
47 lines
1.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Bug 158 and related issues with 8-bit characters due to MR_Char being
|
|
% signed (potentially).
|
|
%
|
|
|
|
:- module char_signed.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module char.
|
|
:- import_module int.
|
|
|
|
main(!IO) :-
|
|
( if char.det_from_int(255) = '\xFF\' then
|
|
io.write_string("unify succeed\n", !IO)
|
|
else
|
|
io.write_string("unify fail\n", !IO)
|
|
),
|
|
( if aa @< '\xFF\' then
|
|
io.write_string("'A' < 0xFF\n", !IO)
|
|
else
|
|
io.write_string("'A' >= 0xFF (wrong)\n", !IO)
|
|
),
|
|
( if '\xFF\' @< aa then
|
|
io.write_string("0xFF < 'A' (wrong)\n", !IO)
|
|
else
|
|
io.write_string("0xFF >= 'A'\n", !IO)
|
|
),
|
|
( if char.to_int('A') < char.to_int('\xFF\') : int then
|
|
io.write_string("'A' < 0xFF\n", !IO)
|
|
else
|
|
io.write_string("'A' >= 0xFF (wrong)\n", !IO)
|
|
).
|
|
|
|
:- func aa = char.
|
|
:- pragma no_inline(aa/0).
|
|
|
|
aa = char.det_from_int(65).
|