mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-17 02:13:54 +00:00
The recent change to sparse_bitsets broke the lex library in extras.
Specifically, we now now need to make characters an instance of the
uenum typeclass. This diff does so.
library/char.m:
Add predicates and functions for converting between unsigned integers
and characters.
Make characters an instance of the uenum typeclass.
tests/hard_coded/Mmakefile:
tests/hard_coded/char_uint_conv.{m,exp,exp2}:
Add a test of the above conversions.
NEWS:
Announce the additions.
extras/lex/lex.m:
Conform to recent changes.
42 lines
1.1 KiB
Plaintext
42 lines
1.1 KiB
Plaintext
Testing uint -> char conversion:
|
||
from_uint(0x0) ==> '\000\'
|
||
from_uint(0x1) ==> '\001\'
|
||
from_uint(0x7f) ==> '\177\'
|
||
from_uint(0x80) ==> '\200\'
|
||
from_uint(0x7ff) ==> '߿'
|
||
from_uint(0x800) ==> 'ࠀ'
|
||
from_uint(0xffff) ==> ''
|
||
from_uint(0x10000) ==> '𐀀'
|
||
from_uint(0x10ffff) ==> ''
|
||
from_uint(0x110000) ==> FAILED
|
||
from_uint(0xfffffffffffffffe) ==> FAILED
|
||
from_uint(0xffffffffffffffff) ==> FAILED
|
||
|
||
Testing char -> uint conversion:
|
||
to_uint('\000\') ==> 0x0
|
||
to_uint('\001\') ==> 0x1
|
||
to_uint('\037\') ==> 0x1f
|
||
to_uint(' ') ==> 0x20
|
||
to_uint('0') ==> 0x30
|
||
to_uint('A') ==> 0x41
|
||
to_uint('Z') ==> 0x5a
|
||
to_uint('a') ==> 0x61
|
||
to_uint('z') ==> 0x7a
|
||
to_uint('~') ==> 0x7e
|
||
to_uint('\177\') ==> 0x7f
|
||
to_uint('\200\') ==> 0x80
|
||
to_uint('\237\') ==> 0x9f
|
||
to_uint(' ') ==> 0xa0
|
||
to_uint('¿') ==> 0xbf
|
||
to_uint('À') ==> 0xc0
|
||
to_uint('ÿ') ==> 0xff
|
||
to_uint('𐀀') ==> 0x10000
|
||
to_uint('𐁝') ==> 0x1005d
|
||
to_uint('🬀') ==> 0x1fb00
|
||
to_uint('🯹') ==> 0x1fbf9
|
||
to_uint('𠀀') ==> 0x20000
|
||
to_uint('𪛟') ==> 0x2a6df
|
||
to_uint('丽') ==> 0x2f800
|
||
to_uint('') ==> 0x2fa1f
|
||
to_uint('') ==> 0x10ffff
|